Skip to content
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

TypeScript compile error due to typings #7369

Closed
hermanfransen opened this issue Mar 3, 2016 · 9 comments
Closed

TypeScript compile error due to typings #7369

hermanfransen opened this issue Mar 3, 2016 · 9 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@hermanfransen
Copy link

I'm using typescript 1.7.5, typings 0.6.9 and angular 2.0.0-beta.0.

How can I get rid of the typescript compile error messages Duplicate identifier due to typings definition files?

The Duplicate identifier error occurs in the definition files of the following directories:

node_modules/angular2/typings/es6-shim/es6-shim.d.ts
node_modules/angular2/typings/jasmine/jasmine.d.ts
node_modules/angular2/typings/zone/zone.d.ts
typings/browser/ambient/es6-promise/es6-promise.d.ts
typings/browser/ambient/es6-shim/es6-shim.d.ts
typings/browser/ambient/jasmine/jasmine.d.ts
typings/browser/ambient/karma/karma.d.ts
typings/browser/ambient/zone.js/zone.js.d.ts

What's the compiler doing in node_modules/angular2 directory since I excluded it in tsconfig.json?

I also posted this question on StackOverflow

tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "system",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
    },
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}

They are gone if I change the exclude part of tsconfig.json:

"exclude": [
    "node_modules",
    "typings"
]

But then after adding the following I get again the same Duplicate identifier compile errors:

/// <reference path="../../typings/browser.d.ts" />

typings.json

{
  "name": "example-mean-app-client",
  "dependencies": {},
  "devDependencies": {},
  "ambientDependencies": {
    "bootstrap": "github:DefinitelyTyped/DefinitelyTyped/bootstrap/bootstrap.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
    "es6-promise": "github:DefinitelyTyped/DefinitelyTyped/es6-promise/es6-promise.d.ts#830e8ebd9ef137d039d5c7ede24a421f08595f83",
    "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
    "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4",
    "karma": "github:DefinitelyTyped/DefinitelyTyped/karma/karma.d.ts#02dd2f323e1bcb8a823269f89e0909ec9e5e38b5",
    "karma-jasmine": "github:DefinitelyTyped/DefinitelyTyped/karma-jasmine/karma-jasmine.d.ts#661e01689612eeb784e931e4f5274d4ea5d588b7",
    "systemjs": "github:DefinitelyTyped/DefinitelyTyped/systemjs/systemjs.d.ts#83af898254689400de8fb6495c34119ae57ec3fe",
    "zone.js": "github:DefinitelyTyped/DefinitelyTyped/zone.js/zone.js.d.ts#9027703c0bd831319dcdf7f3169f7a468537f448"
  }
}
@RyanCavanaugh
Copy link
Member

http://stackoverflow.com/questions/35776470/typescript-compile-error-due-to-typings

Please post a link when you crosspost so we don't duplicate effort

@louy
Copy link

louy commented Mar 3, 2016

Your typings in node_modules/angular2/typings are <reference>d somewhere in your code.

@mhegazy mhegazy added the Question An issue which isn't directly actionable in code label Mar 3, 2016
@rendmath
Copy link

rendmath commented Mar 3, 2016

Same problem here with typings 0.6.9, tsc.exe 1.8.2, launched in Visual Studio from MSBuild.exe through the TypeScript 1.8.4 for Visual Studio 2015 extension ("Compile TypeScript on build").
If my exclude section looks like this :

"exclude": [
    "node_modules",
    "wwwroot",
    "typings"
  ]

... then the compilation fails because the TypeScript compiler "Cannot find name", which seems right enough.

But if I selectively exclude all the subcontent of the same typings directory :

"exclude": [
    "node_modules",
    "wwwroot",
    "typings/browser",
    "typings/main",
    "typings/browser.d.ts",
    "typings/main.d.ts"
  ]

... then I get hundreds of Duplicate identifier errors.

Same thing with this exclude section (just with twice as many errors) :

"exclude": [
    "node_modules",
    "wwwroot",
    "typings/main",
    "typings/main.d.ts"
  ]

But with this last configuration, the build succeeds with the tsc 1.8.7 node module.

Edit: And the only s are in main.d.ts and browser.d.ts.

Edit: Deleting either the main.d.ts or the browser.d.ts file, along with its associated folder, "solves" the problem until the next typings install.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 3, 2016

@rendmath, the issue you describe sounds a lot like #7198. file names in the exclude were not correctly excluded. can you try TS 1.8.5 (https://github.com/Microsoft/TypeScript/releases/tag/v1.8.7) and see if it does address the issue?

@rendmath
Copy link

rendmath commented Mar 3, 2016

Yes, it absolutely solves my problem.

The TypeScript 1.8.6 for Visual Studio 2015 extension doesn't show up in the Visual Studio Gallery, which led me to think that I had the latest version. That was wrong.

Thank you very much for you help.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 3, 2016

thanks for that. it should show up shortly.

@unional
Copy link
Contributor

unional commented Mar 5, 2016

As described above, and to clarify: you need to either exclude {browser,main} that you don't need, or include (files) {browser.d.ts,main.d.ts} that you need:

{
  "exclude": [ "typings/browser", "typings/browser.d.ts" ]
}
// or
{
  "files": [ "typings/main.d.ts" ]
}

Referencing the issue on typings:
typings/typings#151 (comment)

This behavior will change soon.

@hermanfransen
Copy link
Author

I was not aware there were duplicate typings in "node_modules/angular2/typing" and "typings" directory. Deleting duplicate typings solved my problem

@serkanyersen
Copy link

tsd install es6-shim solves this issue without changing anything in the code base

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

7 participants