Skip to content

TypeScript 2.0, tsc issue when having @types in symlinked node_modules #11107

@TautvydasDerzinskas

Description

@TautvydasDerzinskas

Long story short, our build process before firing "npm start" command creates symlink to node_modules folder in the root folder of the project taking it from some other place.

Our npm start command setup in package.json:

  "scripts": {
    "prestart": "npm install",
    "start": "tsc @App/Other/Gulp/preCompile.txt && gulp build",
...
  }

So it does run npm install, but because we symlinked the node_modules and npm detects all packages installed, it jumps into "tsc @App/Other/Gulp/preCompile.txt" but this fails, because compiler tries accessing files both from symlink local folder "node_modules" and original "node_modules", exact lines from log:

> tsc @App/Other/Gulp/preCompile.txt && gulp build
../../../../../../Resources/Development/node_modules/@types/angular/index.d.ts(17,21): error TS2300: Duplicate identifier 'angular'.
../../../../../../Resources/Development/node_modules/@types/angular/index.d.ts(18,21): error TS2300: Duplicate identifier 'ng'.
node_modules/@types/angular/index.d.ts(17,21): error TS2300: Duplicate identifier 'angular'.
node_modules/@types/angular/index.d.ts(18,21): error TS2300: Duplicate identifier 'ng'.

I have tried setting typeroots in tsconfig.json to "node_modules/@types" which is default value, but it did not help. Seems like it could be typescript 2.0 bug, as the original path is relative to the project root...

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions