Search code examples
angulartypescriptasp.net-coreasp.net-core-mvckendo-ui-angular2

Typescript .d.ts Compilation Errors


I am using Visual Studio 2015 Pro to develop a .Net Core Angular 2 project using Systemjs and Kendo UI Angular 2 components.

I am using Gulp to copy library files from node_modules to "wwwroot/shared/lib" and excluding both directories from compilation in tsconfig.json.

Everything works properly until I include a Kendo UI module, which causes typescript to compile .d.ts files in the "node_modules/@progress/[component-name]/dist/npm/js" directory.

I am excluding node_modules in tsconfig.json, so I'm guessing that the Kendo UI component code is somehow referencing the .d.ts files somehow.

When I exclude "wwwroot" instead of "wwwroot/shared/lib", the project compiles without error (because all of my .ts files are in "wwwroot").

The weird thing is that when I change it back to "wwwroot/shared/lib", it still works! But once I restart VS I get the errors again (?!)

All of the errors are specific to .d.ts files in the "node_modules/@progress" folder. There are plenty of .d.ts files in "node_modules/@angular" that aren't causing any problems, so this has to be specific to Kendo UI code.

Is there any way to keep VS from compiling .d.ts files, regardless of their location?

Here is my tsconfig:

"compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
},
"compileOnSave": true,
"exclude": [
    "node_modules",
    "wwwroot/shared/lib"
    //  ,
    //"wwwroot"
]

UPDATE

Seemingly at random, the errors will jump from 6 to 149 - including error TS2304: Cannot find name 'module', 'map', etc...

I've tried adding "skipDefaultLibCheck": true to tsconfig with no luck.

Adding "types": [ "node" ] will cause tsc.exe to exit with code 1, unless I do the trick where I exclude "wwwroot", then run the project, and then include it again.

Everything always works fine after I do that - until I restart VS and everything blows up.

UPDATE 2

I installed the latest version of Typescript for Visual Studio 2015 (TypeScript_Dev14Full), which appears to have resolved most of the aforementioned problems, though I am now left with a new error:

"TS2309 Build:An export assignment cannot be used in a module with other exported elements." on \node_modules\@types\node\index.d.ts

The error appears twice, once for Project: "TypeScript Virtual Projects" and Project: "DevDashLocal".

I rebuilt the project with the newest versions .Net Core SDK and Typescript and am receiving the same errors in the new project.


Solution

  • It appears that the errors were due to an outdated version of Typescript for Visual Studio 2015 being installed. Updating the TS tooling removed the errors referencing Kendo UI