-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RRFC] Detecting and installing Definitely Typed packages #328
Comments
@karlhorky love this idea In the response to Dev dep or regular dep? I suggest a second Those who don't care (setting not present) will have them placed in the dev dependencies by default. |
I wish it's possible to install production and development dependencies in one command: npm i -P react react-dom -D @types/react @types/react-dom If I know DefinitelyTyped package exist, this would combine two commands into one and save a bit of time, without risking a supply chain attack. Originally proposed on Dev. |
I would prefer that we not bake in TypeScript to the CLI. More specifically, there shouldn't be something that's TypeScript specific in commands or flags - rather, TypeScript should be an option passed to a generic flag: npm install styled-components --with-types=typescript # would also install @types/styled-components to devDependencies Alternatively, having a different flag that set what "types" were: npm install styled-components --with-types --types=typescript # would also install @types/styled-components to devDependencies The latter would have the benefit of allowing you to dump |
I agree with the proposal to set types flags instead of hard backing in Typescript. |
Motivation ("The Why")
Originally an issue brought up by @aweary over on
npm/feedback
:I would additionally suggest consideration of an
.npmrc
setting to globally enable this, similar to what @bnb mentioned.Example
If there are already types, no secondary package is installed:
How
Current Behaviour
Users have to manually search for and install the types on DefinitelyTyped.
Desired Behaviour
If:
typings
ortypes
fields are specified in the package.jsonindex.d.ts
file is in the rootThen:
@types
scope is searched for a matching package (see methods below)Methods for searching for matching DefinitelyTyped packages:
Prior Art
There are some userland packages which handle this:
types-installer
typed-install
install-types
Security Concerns
@MylesBorins brought up security concerns with supply chain attacks:
However, the behavior of users currently is to already install the matching
@types
package, as @aweary notes:And also, as I mentioned, there is also a review process for DefinitelyTyped: https://github.com/definitelytyped/definitelytyped/#make-a-pull-request
Dev dep or regular dep?
@ljharb brought up whether the new
@types/pkg
deps should become dev dependencies (feels like dev deps are the right choice for most cases?)References
npm/feedback
discussion: automatically installing the @types package when adding a dependency feedback#174The text was updated successfully, but these errors were encountered: