typescript@next
allows you to use features that will be available in the next TypeScript release.
# Benefits
In my case, I wanted to play with a few TypeScript 2.0 features before it got released, like:
- The
--strictNullChecks
flag (allowing finer control over undefined / nullable properties:myProperty: string | null | undefined
). - The new way to install community types definitions
npm install --save @types/lodash
.
# Setup Visual Studio Code and Atom to use typescript@next
- Install typescript@next:
npm install -g typescript@next
- Note: you can also install it locally to your project.
- Figure out your typescript installation path:
- On Linux it should be:
echo `npm root -g`/typescript/
- In my case it's
/home/usename/Applications/nodejs/lib/node_modules/typescript/
- On Linux it should be:
- [Visual Studio Code] Use typescript@next:
- Open your configuration file:
File
->Preferences
->Workspace Settings
- Note: This will only use typescript@next for your current Visual Studio Code workspace, you can select
User Settings
instead if you want to make the change global.
- Add this line to your configuration file (on the right pane):
"typescript.tsdk": "[YOUR TYPESCRIPT INSTALLATION PATH]/lib"
- Note: Replace
[YOUR TYPESCRIPT INSTALLATION PATH]
with your typescript installation path ;) Don't forget the "/lib" part at the end! - Note 2: Visual Studio Code also accepts relative paths (example:
./node_modules/typescript/lib
)
- Restart Visual Studio Code
- Open your configuration file:
- [Atom Editor] Use typescript@next:
- Install the
atom-typescript
package. - Go to the Settings for the
atom-typescript
package. - Edit
Full path (including file name) to a custom typescriptServices.js
with:[YOUR TYPESCRIPT INSTALLATION PATH]/lib/typescriptServices.js
- Note: Replace
[YOUR TYPESCRIPT INSTALLATION PATH]
with your typescript installation path ;) Don't forget the "/lib/typescriptServices.js" part at the end!
- Restart Atom Editor
- Install the
- Extra - [ts-loader and webpack] - Use typescript@next:
- If you use
ts-loader
to compile your .ts files, just runnpm link typescript
so it can use your globally installed version of typescript.
- If you use
You're done :)