The potential of TS 2.x @types
is intriguing, but I'm struggling to make it work effectively!
- I'm using Visual Studio 2015 - version
14.0.25431.01 Update 3
- My TypeScript version for Visual Studio 2015 is
2.1.4
, downloaded from this link - The VS Web project is configured for TypeScript 2.1 with
<TypeScriptToolsVersion>2.1</TypeScriptToolsVersion>
This snippet is from my packages.json
file
"dependencies": {
"angular": "^1.5.9",
"angular-messages": "^1.5.9",
"angular-ui-bootstrap": "^2.3.0",
"angular-ui-router": "^0.3.2",
"moment": "^2.17.0",
"underscore": "^1.8.3"
},
"devDependencies": {
"@types/angular": "^1.5.21",
"@types/angular-ui-bootstrap": "^0.13.36",
"@types/angular-ui-router": "^1.1.35",
"@types/jquery": "^2.0.34",
"@types/node": "^0.0.3",
"@types/signalr": "^2.2.32",
"@types/underscore": "^1.7.36"
}
And here's my complete tsconfig.json
content
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": true,
"removeComments": true,
"sourceMap": true,
"target": "ES5"
},
"typeAcquisition": {
"enable": true
}
}
I've experimented with different configurations including typeRoots
and types
specified in the compilerOptions
, but without success!
"typeRoots": [
"./node_modules/@types"
],
"types": [
"angular",
"angular-ui-bootstrap",
"angular-ui-router",
"jquery",
"moment",
"signalr",
"underscore"
]
Despite cleaning the build and restarting Visual Studio, I continue to encounter errors like:
some-file.ts(8,22): error TS2304: Build:Cannot find name 'angular'.
some-file.ts(12,41): error TS2694: Build:Namespace 'angular' has no exported member 'IScope'.
some-file.ts(12,67): error TS2694: Build:Namespace 'angular' has no exported member 'IRootElementService'.
another-file.ts(26,22): error TS2503: Build:Cannot find namespace 'moment'.
another-file.ts(47,37): error TS2304: Build:Cannot find name 'moment'.
All necessary typedefs exist either in node_modules/@types
or within the corresponding package itself. I can't fathom why Visual Studio/TypeScript is unable to locate these files! Is there something obvious that I'm overlooking? Any guidance would be greatly appreciated!