I have defined the following Angular2 component:
import {Component} from \'angular2/core\';
@Component({
selector: \'my-app\',
moduleId: module.id,
te
For those looking to do this with Typescript 2.x and @types, here's what you need to do:
npm install -D @types/node
types: ["node"]
under compilerOptions
in your tsconfig.json
file.I had a tough time finding the instructions for step 2.
Reference: Typescript issue 9184
Edit:
You could also do:
"typeRoots": [ "node_modules/@types" ]
under compilerOptions
in your tsconfig.json
file. This is instead of the types
property and has the benefit of automatically including any @types
you install with npm.For example:
{
"compilerOptions": {
"typeRoots": [
"node_modules/@types"
]
}
}
[Second edit]
Apparently, with the latest typescript, you only need typeRoots
or types
if tsconfig.json
is not in the root of your project or your types are not stored in node_modules/@types
.