Typescript: 2.0 @types declarations compiled despite ignore listing in tsconfig

Created on 29 Sep 2016  ·  3Comments  ·  Source: microsoft/TypeScript

TypeScript Version: 2.0.3

Code
Full project here.

tsconfig.json:

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

Expected behavior:

For the project to compile, and as the tsconfig specifies, the node_modules directory to be ignored, hence no errors from that directory.

Actual behavior:

Lots of errors from node_modules/@types directory, e.g. :

[0] node_modules/@types/core-js/index.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'.

[0] node_modules/@types/core-js/index.d.ts(85,5): error TS2687: All declarations of 'name' must have identical modifiers.

[0] node_modules/@types/core-js/index.d.ts(145,5): error TS2403: Subsequent variable declarations must have the same type. Variable '[Symbol.unscopables]' must be of type '{ copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: ...', but here has type 'any'.

[0] node_modules/@types/core-js/index.d.ts(262,5): error TS2687: All declarations of 'flags' must have identical modifiers.

[0] node_modules/@types/core-js/index.d.ts(276,5): error TS2687: All declarations of 'EPSILON' must have identical modifiers.

[0] node_modules/@types/core-js/index.d.ts(311,5): error TS2687: All declarations of 'MAX_SAFE_INTEGER' must have identical modifiers.

Question

Most helpful comment

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false,
        "types": []
    },
    "exclude": [
        "../node_modules"
    ]
}

I believe types should be inside compilerOptions

All 3 comments

@types are automatically included in the compilation. to exclude them, add "types": [] to your tsconfig.json

@mhegazy Even with this as my tsconfig:

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
    },
    "types": [],
    "exclude": [
        "../node_modules"
    ]
}

I still get errors, e.g.

[1] node_modules/@types/core-js/index.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'.

[1] node_modules/@types/core-js/index.d.ts(85,5): error TS2687: All declarations of 'name' must have identical modifiers.
[1] node_modules/@types/core-js/index.d.ts(145,5): error TS2403: Subsequent variable declarations must have the same type. Variable '[Symbol.unscopables]' must be of type '{ copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: ...', but here has type 'any'.

[1] node_modules/@types/core-js/index.d.ts(262,5): error TS2687: All declarations of 'flags' must have identical modifiers.

{
    "compilerOptions": {
        "target": "es6",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false,
        "types": []
    },
    "exclude": [
        "../node_modules"
    ]
}

I believe types should be inside compilerOptions

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dlaberge picture dlaberge  ·  3Comments

kyasbal-1994 picture kyasbal-1994  ·  3Comments

Roam-Cooper picture Roam-Cooper  ·  3Comments

seanzer picture seanzer  ·  3Comments

manekinekko picture manekinekko  ·  3Comments