-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate identifiers #6475
Comments
+1 + 1 + 1... please add ignoreDups flag |
The duplicate identifier is a symptom of another issue. i would like to understand the issue a bit more. Can you elaborate on why you need to copies of bluebird.d.ts (lib/typings/bluebird/bluebird.d.ts and typings/bluebird/bluebird.d.ts), why not have two tsconfig.json and call the compiler twice, once for lib, and once for server? |
I beleive the issue has to do with the trasnpiler not respecting the exclude as in:
since as you can see from my attached image, all issues are a result of the TS still inspecting the node_modules dir |
"exclude" only excludes files in your folder, and its subfolders from being automatically included int he compilation. if you import a module in your code, the compiler will have to pull it in (e.g. can you share your project so that i can understand the project setup? |
@mhegazy, it's quite possible that I'm simply not using the compiler the way it was intended to be used. I'm actually using the one built into WebStorm. My (probably incorrect) assumption was that I could compile my "main" file ( Can you elaborate more on your recommendation on how it should be structured? An example or reference would be helpful. |
@born2net I think i understand the issue now. the main problem is that two packages you are including angular2 and ng2-translate both introduce the same global scope definitions. //CC @alexegel from the angular2 team if he has any recommendations here. Additionally, you were including locally some typings files, like node.d.ts that angular2 packages ships another verison of. I have a PR out for your repo to work around that and demonstrate the issue at: https://github.com/born2net/ng2Boilerplater-webpack/pull/1 At the core, this is the same issue as #4665. @vladima is looking into a fix here. |
@davidleureka can you share your project setup, so that i can understand the problem before making any recommendations. |
tx will check asap! |
I applied your changes but still same dup errors :( |
i built using tsc. how are you building? |
I am building using WebStorm which ships with TS 1.7 https://github.com/born2net/ng2Boilerplater-webpack, same issues :( |
note sure what is going on.. but here is what i see locally: c:\test\ng2-webpack\ng2Boilerplater-webpack>git status
On branch master
Your branch is up-to-date with 'remote/master'.
nothing to commit, working directory clean
c:\test\ng2-webpack\ng2Boilerplater-webpack>git remote
origin
remote
c:\test\ng2-webpack\ng2Boilerplater-webpack>git remote -v
origin https://github.com/born2net/ng2Boilerplater-webpack.git (fetch)
origin https://github.com/born2net/ng2Boilerplater-webpack.git (push)
remote https://github.com/mhegazy/ng2Boilerplater-webpack.git (fetch)
remote https://github.com/mhegazy/ng2Boilerplater-webpack.git (push)
c:\test\ng2-webpack\ng2Boilerplater-webpack>node c:\releases\1.7.3\tsc.js --v
message TS6029: Version 1.7.3
c:\test\ng2-webpack\ng2Boilerplater-webpack>node c:\releases\1.7.3\tsc.js --p .\
c:\test\ng2-webpack\ng2Boilerplater-webpack>echo %ERRORLEVEL%
0 |
re-compiled and LOOKS GOOD now... |
Angular 2 generally causes problems for some users by bundling dependent typings. |
@born2net I didn't understand how you solved it, can you please give some more details ? |
What got fixed here? We're doing a la carte fixes to people's projects?? This is a big problem. Only going to get worse as more folks jump on the Angular 2 bandwagon. I'm using ng2-datepicker and Angular 2 beta 2. I get they're both somehow complaining about moment.js. Can you provide some constructive steps to avoid these collisions? Thanks, |
Angular 2 beta.6 no longer pollutes the type-checker with typings from our dependencies. As Mohamed said earlier #6475 (comment) there is now work going on that would improve the duplicate identifiers problem in the general case. |
@moshie you should bring that up with the maintainers of the phantomjs typings, that's not a TypeScript nor Angular issue. |
I'm having an issue with duplicate identifier errors. It appears to stem from having the same definitions listed in multiple places.
Let's say that I have a simple node server that utilizes the bluebird promise library. I have bluebird used in the main server code and in a library I wrote used by the server code. The structure looks like this:
Here is the code for and for
mylib.ts
:and
server.ts
:As you can see, both
server.ts
andmylib.ts
use the bluebird library. Sinceserver.ts
usesmylib.ts
, it ends up importing bluebird twice, which results in errors. So when I runtsc server.ts --module commonjs
I get
Tools like npm seem to be able to handle this situation. The only way I can get typescript to handle it is by having a single
tsd.json
file and correspondingtypings
folder at the root of my project and having all the typescript definitions live there. Is that the generally accepted way to structure things?The text was updated successfully, but these errors were encountered: