VS Code Automatic Type Acquisition Gotchas

Firstly it works only for pure JS projects ie projects that don’t have any .ts files.

You must have a package.json with the library dependency, coz that’s how TS knows that it needs to download the types for this library silently in the background

You can check the list of packages that support this feature using the list here: %LOCALAPPDATA%\Microsoft\TypeScript\node_modules\types-registry\index.json

Finally, if you want to see where the type declarations for these packages is stored, go here:%LOCALAPPDATA%\Microsoft\TypeScript\node_modules\@types

Lastly, you’ll have to use ES 6 style imports to have intellisense work.

Eg. To have lodash intellisense in your JS project, simply do:

  • npm init
  • create js file
  • npm install –save lodash
  • in the js file, write: import * as _ from ‘lodash’;
  • Then when you do _. you’ll see intellisense working 🙂
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s