I am currently in the process of upgrading a project from Angular JS to Angular 4. The existing Angular JS project already makes use of TypeScript, and upon conversion, I am encountering numerous errors in Visual Studio pertaining to third-party TypeScript typing files (*.d.ts). In addition to these errors, there are also some issues with the actual TypeScript files.
Interestingly, the TypeScript code successfully compiles when using the command-line TypeScript compiler (tsc). Hence, my goal is to prevent compile checking for all *.d.ts files.
I have explored various solutions suggested by others facing similar problems but none seem to work for me, particularly since most of them are tailored for VS 2017.
Here are the steps I've taken thus far to disable compile checking:
Added 'TypeScriptCompileBlocked' to the .csproj file:
<PropertyGroup>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
....
</PropertyGroup>
- Subsequently closed and reopened Visual Studio
Created an .eslintignore file:
In the root of the project, I added an .eslintignore file with rules to ignore all *.d.ts files:
**/*.d.ts
**/node_modules/*
Disabled ESLint:
Despite scouring through VS Tools > Options, I could not find an option to disable ESLint specifically in VS 2015.
Modified tsconfig.json to exclude the node_modules folder:
"exclude": [
"./node_modules/*"
]
-- Additionally tried --
"node_modules"
... and
"**/*.d.ts"
Set "compileOnSave" to false in tsconfig.json:
{
"compilerOptions": {
"compileOnSave": false
}
}
Inclusive of this change, I also specified an empty array within "types": [] under "compilerOptions".
Moreover, I tinkered with several other compilerOptions to disregard errors, however, they do not pertain to the current issues:
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"noStrictGenericChecks": true
What further actions should I take to address the errors related to *.d.ts files? For reference, here's a snippet of some errors found in the file node_modules\@angular\common\src\directives\ng_class.d.ts:
https://i.sstatic.net/0sD4r.jpg
The current configuration details of the project are as follows:
- TSC compiler version = 1.8
- TypeScript version = 2.6.2 (installed via npm)
- No TypeScript configuration options set directly within the Visual Studio project (.csproj file)
Below is the complete tsconfig.json setup:
{
"compilerOptions": {
"target": "es5",
"module": "ES2015",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"noStrictGenericChecks": true
},
"include": [ "**/*.ts" ],
"exclude": [
"node_modules"
]
}
(Regarding the module value used, refer to MicroSoft documentation):
"ES6" and "ES2015" values may be employed when targeting "ES5" or lower.
Link to TypeScript Compiler Options Handbook
As an experiment, I also experimented with setting "commonjs" as the value.