Definitelytyped: @ types / core-jsが実際に使用されていない場合、@ types / core-jsはtypescript / lib /lib.es6.d.tsと競合します

作成日 2016年10月04日  ·  12コメント  ·  ソース: DefinitelyTyped/DefinitelyTyped

単純な複製リポジトリ: httpsnpm i && npm run build後、エラーは次のとおりです。

node_modules/@types/core-js/index.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'.
node_modules/typescript/lib/lib.es6.d.ts(4133,14): error TS2300: Duplicate identifier 'PropertyKey'.

予想: app.tsが空であるため、エラーは発生しません。 @types/core-jsstatic/app.ts使用されます。

  "devDependencies": {
    "@types/core-js": "^0.9.34",
    "core-js": "^2.4.1",
    "typescript": "^2.0.3"
  }
@types

最も参考になるコメント

同様の問題がありました。 追加されました"skipLibCheck": truecompilerOptions私の中にtsconfig.json助けと比べて

全てのコメント12件

lib.es6に含まれていないcore-jsのどの部分が必要ですか? @types/core-jsインストールできませんでしたか?

@ aciccarellocore -jsとstatic/app.tsフロントエンドで使用され、この部分はうまく機能します

2つのtsconfig.json 、1つはバックエンド用(es6、エラーはここで発生)、もう1つはフロントエンド用(es5、エラーなし、正常に動作)、

@ plantain-00あなたはこれを理解しましたか?
同様の問題が発生しており、core-js(Dictionaries)の非標準機能のいくつかを使用したいのですが、タイプがtypescriptsライブラリと競合しています。

@jefbarn非標準機能の場合、解決策はありません。
標準的な機能のために、私はアンインストール@types/core-js 、除去import "core-js";コアJSはES2015 +のpolyfillsであるので、私は使用できるように、 typescript/lib/lib.es6.d.ts代わりに、 tsconfig.json次のようになります:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "lib": [
            "es2015",
            "es5",
            "dom",
            "scripthost"
        ]
    }
}

この問題はまだ必要なようです。これを再開します。

@types\core-jsを使用し、ES6をターゲットにしてこの問題が発生しています

@anorborg私は次のようなものを使用して私の状況を機能させました:

  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "moduleResolution": "node",
    "lib": ["es5", "dom"],
    ...
  }

動作したcore-jsとtypescript 2.x es6.d.tsライブラリは競合しており、typescriptにes6.d.ts使用しないように指示しています。 私は、より_純粋な_解決策は、 core-js定義全体を含めるのではなく、 core-js (つまり、 core-js-es6-object )のモジュールタイプ定義を作成することだと思います。 これをローカルで開始しようとしましたが、ローカルのカスタム型を機能させることができませんでした。 時間があれば、それを理解して、すべてのモジュールのPRを作成しようとします。

注意のためのバンプ。

このtsconfigを使用して、 tsc 2.2.0新しいプロジェクトを作成しました。

{
  "compilerOptions": {
    "outDir": "./build/",
    "rootDir": "./src/",
    "baseUrl": ".",
    "sourceMap": true,
    "noImplicitAny": false,
    "module": "commonjs",
    "target": "es6"
  },
  "include": [
    "./src/**/*.ts"
  ],
  "compileOnSave": false
}

これらのエラーが発生します:

node_modules/@types/core-js/index.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(85,5): error TS2687: All declarations of 'name' must have identical modifiers.
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'.
node_modules/@types/core-js/index.d.ts(262,5): error TS2687: All declarations of 'flags' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(276,5): error TS2687: All declarations of 'EPSILON' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(311,5): error TS2687: All declarations of 'MAX_SAFE_INTEGER' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(318,5): error TS2687: All declarations of 'MIN_SAFE_INTEGER' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(457,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.toStringTag]' must be of type '"Symbol"', but here has type 'string'.
node_modules/@types/core-js/index.d.ts(457,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(464,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(492,5): error TS2687: All declarations of 'hasInstance' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(498,5): error TS2687: All declarations of 'isConcatSpreadable' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(504,5): error TS2687: All declarations of 'iterator' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(510,5): error TS2687: All declarations of 'match' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(516,5): error TS2687: All declarations of 'replace' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(522,5): error TS2687: All declarations of 'search' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(528,5): error TS2687: All declarations of 'species' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(534,5): error TS2687: All declarations of 'split' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(540,5): error TS2687: All declarations of 'toPrimitive' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(546,5): error TS2687: All declarations of 'toStringTag' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(552,5): error TS2687: All declarations of 'unscopables' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(609,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.toStringTag]' must be of type '"Math"', but here has type 'string'.
node_modules/@types/core-js/index.d.ts(609,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(613,5): error TS2403: Subsequent variable declarations must have the same type.  Variable '[Symbol.toStringTag]' must be of type '"JSON"', but here has type 'string'.
node_modules/@types/core-js/index.d.ts(613,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(628,5): error TS2687: All declarations of 'size' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(634,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(645,5): error TS2687: All declarations of 'size' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(651,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(656,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
node_modules/@types/core-js/index.d.ts(664,27): error TS2344: Type 'K' does not satisfy the constraint 'object'.
node_modules/@types/core-js/index.d.ts(665,53): error TS2344: Type 'K' does not satisfy the constraint 'object'.
node_modules/@types/core-js/index.d.ts(666,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(680,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(692,5): error TS2687: All declarations of 'value' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(804,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/typescript/lib/lib.es6.d.ts(4199,14): error TS2300: Duplicate identifier 'PropertyKey'.

ターゲットをes5変更すると、クリーンなビルドになります。

この問題がどのようにあまり注目されていないのかわかりません。 確かに多くの人がTSでES6をターゲットにしようとしていて、これにも遭遇するでしょうか?

@wyqydsyq core.jsとES6はどちらも、多くの同じ定義を定義しています。 tsconfigに@types / core.jsを含めないか、 "lib":["es5"、 "dom"]を設定してください

私も同様の種類の対立を抱えています。

1> c:\ Program Files(x86)\ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es2015.iterable.d.ts(203,11):エラーTS2300:ビルド:重複する識別子 'Promise'。1> c:\ Program Files(x86)\ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es2015.promise.d.ts(223,13):エラーTS2300:ビルド:重複する識別子 'Promise'。1> c:\ Program Files(x86)\ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es2015.symbol.wellknown.d.ts(168,11):エラーTS2300:ビルド:重複識別子 'Promise'。1> c:\ Program Files(x86)\ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es5.d.ts(1292,11):エラーTS2300:ビルド:重複識別子 'Promise'。1> c:\ users \ username \ node_modules \ @types \ es6-promise \ index.d.ts(11,15):エラーTS2300:ビルド:重複する識別子「Promise」。1> c:\ users \ username \ node_modules \ @types \ es6-promise \ index.d.ts(42,19):エラーTS2300:ビルド:重複する識別子「Promise」。

tsconfig:-

{{
"compilerOptions":{
"ターゲット": "es5"、
"モジュール": "commonjs"、
"moduleResolution": "ノード"、
"sourceMap":true、
"emitDecoratorMetadata":true、
「experimentalDecorators」:true、
"lib":["es2015"、 "dom"]、
"noImplicitAny":true、
"suppressImplicitAnyIndexErrors":true、
"noStrictGenericChecks":true
}
}

Package.Json:

{
  "name": "angular-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "build": "tsc -p src/",
    "build:watch": "tsc -p src/ -w",
    "build:e2e": "tsc -p e2e/",
    "serve": "lite-server -c=bs-config.json",
    "serve:e2e": "lite-server -c=bs-config.e2e.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pree2e": "npm run build:e2e",
    "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
    "preprotractor": "webdriver-manager update",
    "protractor": "protractor protractor.config.js",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "test:once": "karma start karma.conf.js --single-run",
    "lint": "tslint ./src/**/*.ts -t verbose"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular/common": "~4.3.4",
    "@angular/compiler": "~4.3.4",
    "@angular/core": "~4.3.4",
    "@angular/forms": "~4.3.4",
    "@angular/http": "~4.3.4",
    "@angular/platform-browser": "~4.3.4",
    "@angular/platform-browser-dynamic": "~4.3.4",
    "@angular/router": "~4.3.4",
    "angular-in-memory-web-api": "~0.3.0",
    "systemjs": "0.19.40",
    "core-js": "^2.4.1",
    "rxjs": "5.0.1",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "concurrently": "^3.2.0",
    "lite-server": "^2.2.2",
    "typescript": "2.6.0",
    "canonical-path": "0.0.2",
    "tslint": "^3.15.1",
    "lodash": "^4.16.4",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "@types/node": "^6.0.46",
    "@types/jasmine": "2.5.36"
  },
  "repository": {}
}

npm 5.5.1
ノード8.9.1

回避策はありますか?

同様の問題がありました。 追加されました"skipLibCheck": truecompilerOptions私の中にtsconfig.json助けと比べて

やあ

./node_modules/@types/core-js/index.d.ts:1461:36-エラーTS2339:プロパティ 'for'はタイプ 'SymbolConstructor'に存在しません。

1461 const _for:typeof core.Symbol.for;
~~~

../node_modules/@types/core-js/index.d.ts:1465:43-エラーTS2339:プロパティ 'hasInstance'はタイプ 'SymbolConstructor'に存在しません。

1465 const hasInstance:typeof core.Symbol.hasInstance;
~~~

../node_modules/@types/core-js/index.d.ts:1469:50-エラーTS2339:プロパティ 'isConcatSp読み取り可能'はタイプ 'SymbolConstructor'に存在しません。

1469 const isConcatSp読み取り可能:typeof core.Symbol.isConcatSp読み取り可能;
~~~ ~~~

../node_modules/@types/core-js/index.d.ts:1477:38-エラーTS2339:プロパティ「keyFor」はタイプ「SymbolConstructor」に存在しません。

1477 const keyFor:typeof core.Symbol.keyFor;
~~

../node_modules/@types/core-js/index.d.ts:1481:37-エラーTS2339:プロパティ「match」はタイプ「SymbolConstructor」に存在しません。

1481 const match:typeof core.Symbol.match;

../node_modules/@types/core-js/index.d.ts:1485:39-エラーTS2339:プロパティ「replace」はタイプ「SymbolConstructor」に存在しません。

1485 const replace:typeof core.Symbol.replace;
~~

../node_modules/@types/core-js/index.d.ts:1489:38-エラーTS2339:プロパティ「search」はタイプ「SymbolConstructor」に存在しません。

1489 const search:typeof core.Symbol.search;
~~

../node_modules/@types/core-js/index.d.ts:1493:39-エラーTS2339:プロパティ「species」はタイプ「SymbolConstructor」に存在しません。

1493 const種:typeof core.Symbol.species;
~~

../node_modules/@types/core-js/index.d.ts:1497:37-エラーTS2339:プロパティ「split」はタイプ「SymbolConstructor」に存在しません。

1497 const split:typeof core.Symbol.split;

../node_modules/@types/core-js/index.d.ts:1501:43-エラーTS2339:プロパティ 'toPrimitive'はタイプ 'SymbolConstructor'に存在しません。

1501 const toPrimitive:typeof core.Symbol.toPrimitive;
~~~

../node_modules/@types/core-js/index.d.ts:1505:43-エラーTS2339:プロパティ 'toStringTag'はタイプ 'SymbolConstructor'に存在しません。

1505 const toStringTag:typeof core.Symbol.toStringTag;
~~~

../node_modules/@types/core-js/index.d.ts:1509:43-エラーTS2339:プロパティ「unscopables」はタイプ「SymbolConstructor」に存在しません。

1509 const unscopables:typeof core.Symbol.unscopables;
~~~

../node_modules/@types/core-js/index.d.ts:2272:36-エラーTS2339:プロパティ 'for'はタイプ 'SymbolConstructor'に存在しません。

2272 const _for:typeof core.Symbol.for;
~~~

../node_modules/@types/core-js/index.d.ts:2276:43-エラーTS2339:プロパティ 'hasInstance'はタイプ 'SymbolConstructor'に存在しません。

2276 const hasInstance:typeof core.Symbol.hasInstance;
~~~

../node_modules/@types/core-js/index.d.ts:2280:50-エラーTS2339:プロパティ 'isConcatSp読み取り可能'はタイプ 'SymbolConstructor'に存在しません。

2280 const isConcatSp読み取り可能:typeof core.Symbol.isConcatSp読み取り可能;
~~~ ~~~

../node_modules/@types/core-js/index.d.ts:2288:38-エラーTS2339:プロパティ 'keyFor'はタイプ 'SymbolConstructor'に存在しません。

2288 const keyFor:typeof core.Symbol.keyFor;
~~

../node_modules/@types/core-js/index.d.ts:2292:37-エラーTS2339:プロパティ「match」はタイプ「SymbolConstructor」に存在しません。

2292 const match:typeof core.Symbol.match;

../node_modules/@types/core-js/index.d.ts:2296:39-エラーTS2339:プロパティ 'replace'はタイプ 'SymbolConstructor'に存在しません。

2296 const replace:typeof core.Symbol.replace;
~~

../node_modules/@types/core-js/index.d.ts:2300:38-エラーTS2339:プロパティ「search」はタイプ「SymbolConstructor」に存在しません。

2300 const search:typeof core.Symbol.search;
~~

../node_modules/@types/core-js/index.d.ts:2304:39-エラーTS2339:プロパティ 'species'はタイプ 'SymbolConstructor'に存在しません。

2304 const種:typeof core.Symbol.species;
~~

../node_modules/@types/core-js/index.d.ts:2308:37-エラーTS2339:プロパティ「split」はタイプ「SymbolConstructor」に存在しません。

2308 const split:typeof core.Symbol.split;

../node_modules/@types/core-js/index.d.ts:2312:43-エラーTS2339:プロパティ 'toPrimitive'はタイプ 'SymbolConstructor'に存在しません。

2312 const toPrimitive:typeof core.Symbol.toPrimitive;
~~~

../node_modules/@types/core-js/index.d.ts:2316:43-エラーTS2339:プロパティ 'toStringTag'はタイプ 'SymbolConstructor'に存在しません。

2316 const toStringTag:typeof core.Symbol.toStringTag;
~~~

../node_modules/@types/core-js/index.d.ts:2320:43-エラーTS2339:プロパティ「unscopables」はタイプ「SymbolConstructor」に存在しません。

2320 const unscopables:typeof core.Symbol.unscopables;
~~~

これは私が得ているエラーです

私のtsconfig
{{
"compileOnSave":false、
"compilerOptions":{
"baseUrl": ""、
"outDir": "./dist/out-tsc"、
"sourceMap":true、
「宣言」:false、
"downlevelIteration":true、
「experimentalDecorators」:true、
"モジュール": "es6"、
"moduleResolution": "ノード"、
「importHelpers」:true、
"ターゲット": "es5"、
"typeRoots":[
"node_modules / @ types"
]、
"lib":[
「es5」、
「es2015」、
「es2017」、
「dom」、
「scripthost」
]、
}、
"angularCompilerOptions":{
"fullTemplateTypeCheck":true、
"strictInjectionParameters":true
}
}
問題を解決するのを手伝ってください

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