Typescript: 2.0 tsconfigのリストを無視しても、@ types宣言がコンパイルされました

作成日 2016年09月29日  ·  3コメント  ·  ソース: microsoft/TypeScript

TypeScriptバージョン: 2.0.3

コード
完全なプロジェクトはこちら

tsconfig.json

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

予想される行動:

プロジェクトをコンパイルする場合、およびtsconfigで指定されているように、 node_modulesディレクトリは無視されるため、そのディレクトリからのエラーは発生しません。

実際の動作:

node_modules/@typesディレクトリからの多くのエラー。例:

[0] node_modules / @ types / core-js / index.d.ts(21,14):エラーTS2300:識別子 'PropertyKey'が重複しています。

[0] node_modules / @ types / core-js / index.d.ts(85,5):エラーTS2687:「name」のすべての宣言には同一の修飾子が必要です。

[0] node_modules / @ types / core-js / index.d.ts(145,5):エラーTS2403:後続の変数宣言は同じ型である必要があります。 変数 '[Symbol.unscopables]'はタイプ '{copyWithin:boolean;である必要があります。 エントリ:ブール値; 塗りつぶし:ブール値; 検索:ブール値; findIndex:ブール値; キー:... 'ですが、ここではタイプ' any 'があります。

[0] node_modules / @ types / core-js / index.d.ts(262,5):エラーTS2687:「フラグ」のすべての宣言には同一の修飾子が必要です。

[0] node_modules / @ types / core-js / index.d.ts(276,5):エラーTS2687:「EPSILON」のすべての宣言には同一の修飾子が必要です。

[0] node_modules / @ types / core-js / index.d.ts(311,5):エラーTS2687:「MAX_SAFE_INTEGER」のすべての宣言には同一の修飾子が必要です。

Question

最も参考になるコメント

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

タイプはcompilerOptions中にあるべきだと思います

全てのコメント3件

@typesは自動的にコンパイルに含まれます。 それらを除外するには、tsconfig.jsonに"types": []を追加します

@mhegazyこれを私のtsconfigとしても:

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

それでもエラーが発生します。

[1] node_modules / @ types / core-js / index.d.ts(21,14):エラーTS2300:識別子 'PropertyKey'が重複しています。

[1] node_modules / @ types / core-js / index.d.ts(85,5):エラーTS2687:「name」のすべての宣言には同一の修飾子が必要です。
[1] node_modules / @ types / core-js / index.d.ts(145,5):エラーTS2403:後続の変数宣言は同じ型である必要があります。 変数 '[Symbol.unscopables]'はタイプ '{copyWithin:boolean;である必要があります。 エントリ:ブール値; 塗りつぶし:ブール値; 検索:ブール値; findIndex:ブール値; キー:... 'ですが、ここではタイプ' any 'があります。

[1] node_modules / @ types / core-js / index.d.ts(262,5):エラーTS2687:「フラグ」のすべての宣言には同一の修飾子が必要です。

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

タイプはcompilerOptions中にあるべきだと思います

このページは役に立ちましたか?
0 / 5 - 0 評価