Skip to content

Latest commit

Β 

History

History
Β 
Β 

plugin-typescript

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

@yarnpkg/plugin-typescript

This plugin automatically adds @types/ packages into your dependencies when you add a package that's covered by one.

Note that for performance reasons the plugin doesn't try to check whether the added package contains its own types - so you might end up with extraneous type packages in some cases.

Usage

Note: This plugin (as all other Yarn plugins) is only compatible with Yarn 2. Yarn 2 is still in a "developer preview" state, meaning that you're welcome to use it and give us your feedback but you might have to get your hands a little dirty to dive into the mechanic.

  1. Install Yarn

  2. Install the @yarnpkg/plugin-typescript plugin:

    $ yarn plugin import @yarnpkg/plugin-typescript
    

Example

❯ yarn/packages/plugin-typescript ❯ yarn add lodash

➀ BR0000: β”Œ Resolution step
➀ BR0002: β”‚ babel-preset-jest@npm:24.1.0 doesn't provide @babel/core@^7.0.0-0 requested by @babel/plugin-syntax-object-rest-spread@npm:7.2.0
➀ BR0000: β”” Completed in 0.24s
➀ BR0000: β”Œ Fetch step
➀ BR0013: β”‚ @types/lodash@npm:4.14.121 can't be found in the cache and will be fetched from the remote registry
➀ BR0000: β”” Completed in 3.63s
➀ BR0000: β”Œ Link step
➀ BR0005: β”‚ webpack-cli@npm:3.2.1 lists build scripts, but its build has been explicitly disabled through configuration.
➀ BR0005: β”‚ fsevents@npm:1.2.6 lists build scripts, but its build has been explicitly disabled through configuration.
➀ BR0005: β”‚ webpack-cli@npm:3.2.1 lists build scripts, but its build has been explicitly disabled through configuration.
➀ BR0005: β”‚ webpack-cli@npm:3.2.1 lists build scripts, but its build has been explicitly disabled through configuration.
➀ BR0000: β”” Completed in 2.75s
➀ BR0000: Done with warnings in 6.81s

As you can see in the fetch step, even though we only added lodash into our dependencies, Yarn automatically figured out that we would need @types/lodash and added it.