Definitelytyped: @ types / core-js entra en conflicto con typecript / lib / lib.es6.d.ts cuando @ types / core-js no se usa realmente

Creado en 4 oct. 2016  ·  12Comentarios  ·  Fuente: DefinitelyTyped/DefinitelyTyped

Un repositorio de reproducción simple: https://github.com/plantain-00/test , después de npm i && npm run build , el error es:

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'.

Se esperaba: sin error, porque app.ts está vacío. el @types/core-js se usa en static/app.ts .

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

Comentario más útil

Tuvo el problema similar. Agregué "skipLibCheck": true a compilerOptions en mi tsconfig.json y luego ayudó

Todos 12 comentarios

¿Qué parte de core-js se necesita que no esté incluida en lib.es6? ¿No podrías simplemente no instalar @types/core-js ?

@aciccarello core-js y @ types / core-js es usado por frontend en static/app.ts , esta parte funciona bien

Hay 2 tsconfig.json , uno para backend (es6, el error ocurre aquí) y el otro para frontend (es5, sin error, funciona bien),

@ plátano-00 ¿Descubriste esto?
Tengo un problema similar, donde quiero usar algunas de las características no estándar de core-js (diccionarios), pero los tipos entran en conflicto con la biblioteca de mecanografiados.

@jefbarn Para
Para las funciones estándar, desinstalé @types/core-js y eliminé import "core-js"; , porque core-js es polyfills de ES2015 +, por lo que puedo usar typescript/lib/lib.es6.d.ts lugar, el tsconfig.json parece:

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

Parece que este problema todavía es necesario, lo volveré a abrir.

Tengo este problema al usar @types\core-js y apuntar a ES6

@anorborg Conseguí que mi situación funcionara usando algo como esto:

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

@jefbarn que funcionó. Básicamente, las bibliotecas de core-js y mecanografiado 2.x es6.d.ts están en conflicto y eso le está diciendo a mecanografiado que no use su es6.d.ts . Creo que la solución más pura es crear algunas definiciones de tipo de módulo para core-js (es decir, core-js-es6-object ) en lugar de incluir la definición completa de core-js . Intenté iniciar esto localmente, pero no pude hacer funcionar los tipos personalizados locales. Si tengo tiempo, intentaré resolverlo y crear un PR para todos los módulos.

Golpe para llamar la atención.

Acabo de crear un nuevo proyecto con tsc 2.2.0 usando esta configuración ts:

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

Lo que produciría estos errores:

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'.

Cambiar el objetivo a es5 da como resultado una construcción limpia.

No estoy seguro de cómo este tema ha recibido tan poca atención; Seguramente muchas personas están tratando de apuntar a ES6 con TS y también se encontrarían con esto.

@wyqydsyq core.js y ES6 definen muchas de las mismas definiciones. No incluya @ types / core.js o establezca "lib": ["es5", "dom"], en su tsconfig

También estoy teniendo un tipo de conflicto similar.

1> c: \ Archivos de programa (x86) \ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es2015.iterable.d.ts (203,11): error TS2300: Compilación: Identificador duplicado 'Promesa'.1> c: \ Archivos de programa (x86) \ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es2015.promise.d.ts (223,13): error TS2300: Compilación: Identificador duplicado 'Promesa'.1> c: \ Archivos de programa (x86) \ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es2015.symbol.wellknown.d.ts (168,11): error TS2300: Compilación: Identificador duplicado 'Promesa'.1> c: \ Archivos de programa (x86) \ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es5.d.ts (1292,11): error TS2300: Compilación: Identificador duplicado 'Promesa'.1> c: \ users \ username \ node_modules \ @types \ es6-promise \ index.d.ts (11,15): error TS2300: Build: Identificador duplicado 'Promise'.1> c: \ users \ username \ node_modules \ @types \ es6-promise \ index.d.ts (42,19): error TS2300: Build: Identificador

tsconfig: -

{
"compilerOptions": {
"target": "es5",
"módulo": "commonjs",
"moduleResolution": "nodo",
"sourceMap": verdadero,
"emitDecoratorMetadata": verdadero,
"experimentalDecorators": verdadero,
"lib": ["es2015", "dom"],
"noImplicitAny": verdadero,
"suppressImplicitAnyIndexErrors": verdadero,
"noStrictGenericChecks": verdadero
}
}

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
nodo 8.9.1

¿Alguna solución?

Tuvo el problema similar. Agregué "skipLibCheck": true a compilerOptions en mi tsconfig.json y luego ayudó

Hola

./node_modules/@types/core-js/index.d.ts:1461:36 - error TS2339: la propiedad 'for' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:1465:43 - error TS2339: la propiedad 'hasInstance' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:1469:50 - error TS2339: la propiedad 'isConcatSpreadable' no existe en el tipo 'SymbolConstructor'.

1469 const isConcatSpreadable: typeof core.Symbol.isConcatSpreadable;
~ ~ ~ ~~~

../node_modules/@types/core-js/index.d.ts:1477:38 - error TS2339: la propiedad 'keyFor' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:1481:37 - error TS2339: la propiedad 'coincidencia' no existe en el tipo 'SymbolConstructor'.

1481 const match: typeof core.Symbol.match;
~

../node_modules/@types/core-js/index.d.ts:1485:39 - error TS2339: la propiedad 'reemplazar' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:1489:38 - error TS2339: la propiedad 'búsqueda' no existe en el tipo 'SymbolConstructor'.

1489 búsqueda constante: typeof core.Symbol.search;
~ ~

../node_modules/@types/core-js/index.d.ts:1493:39 - error TS2339: la propiedad 'especie' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:1497:37 - error TS2339: la propiedad 'split' no existe en el tipo 'SymbolConstructor'.

1497 const split: typeof core.Symbol.split;
~

../node_modules/@types/core-js/index.d.ts:1501:43 - error TS2339: la propiedad 'toPrimitive' no existe en el tipo 'SymbolConstructor'.

1501 const toPrimitive: tipo de core.Symbol.toPrimitive;
~ ~ ~

../node_modules/@types/core-js/index.d.ts:1505:43 - error TS2339: la propiedad 'toStringTag' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:1509:43 - error TS2339: la propiedad 'unscopables' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:2272:36 - error TS2339: la propiedad 'for' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:2276:43 - error TS2339: la propiedad 'hasInstance' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:2280:50 - error TS2339: la propiedad 'isConcatSpreadable' no existe en el tipo 'SymbolConstructor'.

2280 const isConcatSpreadable: typeof core.Symbol.isConcatSpreadable;
~ ~ ~ ~~~

../node_modules/@types/core-js/index.d.ts:2288:38 - error TS2339: la propiedad 'keyFor' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:2292:37 - error TS2339: la propiedad 'coincidencia' no existe en el tipo 'SymbolConstructor'.

2292 const match: typeof core.Symbol.match;
~

../node_modules/@types/core-js/index.d.ts:2296:39 - error TS2339: la propiedad 'reemplazar' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:2300:38 - error TS2339: la propiedad 'búsqueda' no existe en el tipo 'SymbolConstructor'.

2300 búsqueda constante: typeof core.Symbol.search;
~ ~

../node_modules/@types/core-js/index.d.ts:2304:39 - error TS2339: la propiedad 'especie' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:2308:37 - error TS2339: la propiedad 'split' no existe en el tipo 'SymbolConstructor'.

2308 const split: typeof core.Symbol.split;
~

../node_modules/@types/core-js/index.d.ts:2312:43 - error TS2339: la propiedad 'toPrimitive' no existe en el tipo 'SymbolConstructor'.

2312 const toPrimitive: tipo de core.Symbol.toPrimitive;
~ ~ ~

../node_modules/@types/core-js/index.d.ts:2316:43 - error TS2339: la propiedad 'toStringTag' no existe en el tipo 'SymbolConstructor'.

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

../node_modules/@types/core-js/index.d.ts:2320:43 - error TS2339: la propiedad 'unscopables' no existe en el tipo 'SymbolConstructor'.

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

Este es el error que recibo

mi tsconfig
{
"compileOnSave": falso,
"compilerOptions": {
"baseUrl": "",
"outDir": "./dist/out-tsc",
"sourceMap": verdadero,
"declaración": falso,
"downlevelIteration": verdadero,
"experimentalDecorators": verdadero,
"módulo": "es6",
"moduleResolution": "nodo",
"importHelpers": verdadero,
"target": "es5",
"typeRoots": [
"node_modules / @ tipos"
],
"lib": [
"es5",
"es2015",
"es2017",
"dom",
"pantallaso"
],
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": verdadero,
"StrictInjectionParameters": verdadero
}
}
ayúdame a resolver el problema

¿Fue útil esta página
0 / 5 - 0 calificaciones