I've tried to remove typings from my web project (Visual Studio 2015 Community) and install d.ts files via new NPM @types (typescript 2.0.3) in package.json:
"dependencies": {
"@types/angular": "^1.5.8",
"@types/angular-cookies": "^1.4.2",
"@types/angular-local-storage": "^0.1.33",
"@types/angular-material": "^1.1.37",
"@types/angular-translate": "^2.4.33",
"@types/lodash": "^4.14.36"
}
Visual Studio's IntelliSense worked nicely with typings before because I included typings folder in my VS project. NPM installs types into node_modules/@types
folder. Now here is my problem. I don't really want to include anything from node_modules
in VS project.
node_modules
folder should be fine to get deleted and recreated again by npm at will.
Visual Studio does not recognize the typings installed without them being included in the project!
I guess I could create a file with ///reference tags in it but then I would have to maintain this file manually when installing/removing typings.
Is there any recommended way to make VS IntelliSense work?
Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc . You will need to install the TypeScript compiler either globally or in your workspace to transpile TypeScript source code to JavaScript ( tsc HelloWorld. ts ). You can test your install by checking the version.
The @types npm organization is for obtaining type definitions with npm . Using these type definitions is a feature is coming in TypeScript 2.0. This will replace the current projects/tools such as typings and tsd, though these will continue to be supported for some time. Follow this answer to receive notifications.
TypeScript supportBy default, Visual Studio 2022 provides language support for JavaScript and TypeScript files to power IntelliSense without any specific project configuration. For compiling TypeScript, Visual Studio gives you the flexibility to choose which version of TypeScript to use on a per-project basis.
I was struggling with this same problem after making the switch to 2.0 and using the new @types convention.
I found this useful property after looking into the spec for the tsconfig.json here: http://json.schemastore.org/tsconfig
"typeRoots" property of compilerOptions.
I could not get the files or include arrays to pull in my typings, but this seems to have done the trick for me.
My tsconfig.json file as an example:
{
"compileOnSave": true,
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es5",
"jsx": "react",
"typeRoots": [
"node_modules/@types"
]
}
}
Hope this helps someone with the same issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With