TypeScript Version: Latest downloaded for Visual Studio 2015
ASP.NET Core project with Angular 2 worked perfectly until we upgraded to V2 from the TypeScript website downloading tools for VS2015. Then we got literally 1000s of errors. Removed every reference to typings and instead imported @types/node and referenced in tsconfig as shown below. Now we get just the one error shown in the title. Several people have this online but no answers how to fix. We are a small company and have wasted 10s of hours costing us literally hundreds of pounds in lost development time. What does this error mean and how is it fixed desperate for help?
Code
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es5",
"sourceMap": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"skipDefaultLibCheck": true,
"outDir": "../wwwroot/app",
"lib": [ "es6", "dom" ],
"types": [ "node" ]
},
"exclude": [ "bin", "node_modules" ]
}
// A *self-contained* demonstration of the problem follows...
Expected behavior:
Successful build in VisualStudio 2015 of an Angular 2 web app in ASP.NET Core website
Actual behavior:
Fails with one error -
Severity Code Description Project File Line Suppression State
Error TS2309 Build:An export assignment cannot be used in a module with other exported elements. XXX.WebApp C:\Projects\XXX\XXX.WebApp\node_modules\@types\node\index.d.ts 3626
do you have any other instance of declare module "assert" { .. } in your project?
Fantastic mhegazy!!! In our wwwroot file in a lib subfolder called reflect-metadata there was an old file lingering that I guess is from when we were using typings. Deleting this solved the issue saved us so much time, hugely appreciated!
glad that got resolved. I would love to know what other issues you ran into when you upgraded. we do not expect migrating from 1.8 to 2.0 would be that hard. so your feedback would be highly appreciated to make sure this does not happen in future releases.
Basically we made the decision to upgrade to TS V2 , the lastest ASP.NET Core release and Angular 2 packages. ASP.NET Core and Angular 2 went well everything built fine. The first time I installed TypeScript 2 through the website downloading the tools for VS 2015 it said it was successful but I ended up loosing all TS intellisense. When I went to the VS options for Text Editor and selected TypeScript the dialog box reported there was an exception loading the settings. A repair of VS and TS couldn't resolve so I did a full clean install of Visual Studio and TS and that seemed to go OK think that was just bad luck though as I was the only person in the team with this issue. Next problem was that we then got just over 2000+ TS errors many of these were 'Duplicate identifier export=' as well as others. Suggestions on StackOverflow pointed us in the direction of our typings use and suggestions we move to @types. We deleted all our typings references (Or so we thought) and imported the @types/node package and that left us with the single error above. I think the main issue here is that the QuickStart guide we followed for getting Angular2 working with ASP.NET Core and SystemJS involved a lot of unnecessary files being copied to wwwroot through a Gulp task and these hung around causing compilation issues when we upgraded. I don't think our problem was an issue with the TypeScript installation experience more the lack of resources on how to properly set up an Angular 2 app in an ASP.NET Core website. Also instruction on how to get this working in a source controlled environment as this is a real pain point when JS files are created by the compiler constant errors about read only files! All these frameworks are new so I guess it's to be expected and equally my team need to improve our knowledge about how all these frameworks and tools work together. Thanks again for your help mhegazy.
I am getting this problem as well. I am following Angular 2 Tour of Heroes tutorial. The only file I could find containing that is node.d.ts
//node.d.ts
declare module "assert" {
function ok(test: any, message?: string): void;
function fail(message?: string): void;
function equal(actual: any, expected: any, message?: string): void;
function notEqual(actual: any, expected: any, message?: string): void;
function deepEqual(actual: any, expected: any, message?: string): void;
function notDeepEqual(actual: any, expected: any, message?: string): void;
function strictEqual(actual: any, expected: any, message?: string): void;
function notStrictEqual(actual: any, expected: any, message?: string): void;
function throws(block: () => void, error?: ErrorConstructor | RegExp | ((err: any) => boolean), message?: string): void;
function doesNotThrow(block: () => void, message?: string): void;
function ifError(value: any): boolean;
}
This file is copied by gulp to our scripts\app folder. I will try to downgrade Visual Studio Typescript to 1.8 and see what happens.
rosdi, any luck on downgrading?
I have same problem with elasticsearch.d.ts
Most helpful comment
Fantastic mhegazy!!! In our wwwroot file in a lib subfolder called reflect-metadata there was an old file lingering that I guess is from when we were using typings. Deleting this solved the issue saved us so much time, hugely appreciated!