问题
I'm trying to convert a project from Angular 1 to Angular 2.
This is a client & server project with some common code (so I keep it together). I want to use Angular 2 on the client side so I followed the ng2 QuickStart. I am currently trying to build it inside my project.
I am using TSD
to manage my dependencies typings. Some of these dependencies like socket.io
rely on node.d.ts
.
My problem is that angular2
already expose node.d.ts
and create an ambient definition so when I want to use TSD
with angular2
I get a conflict between the two definitions :
typings\node\node.d.ts(961,9): error TS2300: Duplicate identifier 'path'.
Here is my gulp task :
gulp.task('build.conflict', function(){
var browserProject = tsc.createProject('browser.tsconfig.json', {
typescript: typescript
});
var src = [
'src/browser/**/*.ts',
'typings/**/*.d.ts' // commenting out this line results in unknown modules
];
var result = gulp.src(src)
.pipe(tsc(browserProject));
return result.js
.pipe(gulp.dest('build/browser'));
});
I also set up a simple repository demonstrating my issue.
How can I solve this error while still keeping my TSD
typings. (The best solution would be to prevent angular2
to expose its internal node.d.ts
)
回答1:
If you started using Typings, you could only allow discovering *.d.ts
from browser dependencies in tsconfig.json
. Here is an excellent example at John Papa's NgConf demo.
UPDATE: This is outdated per Typings > 1.0.0.
来源:https://stackoverflow.com/questions/34207110/duplicate-identifier-errors-with-angular2-and-tsd