SolvedDefinitelyTyped @types/core-js breaks build in version 0.9.37

  • I tried using the @types/xxxx package and had problems.
  • I tried using the latest stable version of tsc. https://www.npmjs.com/package/typescript
  • I have a question that is inappropriate for StackOverflow. (Please ask any appropriate questions there).
  • Mention the authors (see Definitions by: in index.d.ts) so they can respond.

It seems that there is some issues with the 0.9.37 core-js package and tsc 2.2.1

I get a lot of compiler errors: (just a clipout of them)
node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2693: 'Map' only refers to a type, but is being used as a value here.
node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2693: 'Set' only refers to a type, but is being used as a value here.
node_modules/@types/core-js/index.d.ts(47,36): error TS2304: Cannot find name 'Iterable'.
node_modules/@types/core-js/index.d.ts(350,48): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(351,52): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(352,34): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(353,34): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(354,34): error TS2304: Cannot find name 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(355,61): error TS2304: Cannot find name 'PropertyKey'.
.....
node_modules/@types/core-js/index.d.ts(2103,41): error TS2339: Property 'toStringTag' does not exist on type 'SymbolConstructor'.
node_modules/@types/core-js/index.d.ts(2107,41): error TS2339: Property 'unscopables' does not exist on type 'SymbolConstructor'.
node_modules/rxjs/Observable.d.ts(69,60): error TS2693: 'Promise' only refers to a type, but is being used as a value here.
node_modules/rxjs/operator/toPromise.d.ts(3,79): error TS2693: 'Promise' only refers to a type, but is being used as a value here.
typescript\shared\login.component.ts(81,62): error TS2339: Property 'find' does not exist on type 'Unit[]'.
typescript\shared\login.component.ts(81,62): error TS2339: Property 'find' does not exist on type 'Unit[]'.

With the 0.9.35 everything works as expected.

I am wondering if it is the change in ts.config from es5 to ef2017 that causes this? Can't really see that any of the other changes could have done this?

42 Answers

✔️Accepted Answer

By adding

"lib": ["es2017", "dom"]

to my compilerOptions in tsconfig.json solved this issue for me.

thanks @andy-ms

Other Answers:

We are also getting a lot of errors here. (Cannot find name "Promise", Cannot find name "Set", ...)
Reverting back to 0.9.36 solves the issue for us at this moment.

@dozer75 check out this link: [typescript compiler options].(https://www.typescriptlang.org/docs/handbook/compiler-options.html)

If you are modifying your tsconfig.json file, add a property of lib with an array of strings specifying which libraries to include. For me, I was using @types/core-js in a node server environment (with target es5, i.e. my typescript was being compiled to es5 for production) so I just added "es2015" and everything worked fine. It looks like if you are in a browser environment, adding "dom" will give you standard javascript window and stuff like that too.

I have let this open for a long time now, because all things that are written here are in my opinion workarounds, not solutions.

Isn't this anything that is going to be solved in the definition package itself?

As other states, by adding lib entry in tsconfig it works, but it also renders this package uneccessary, why do we need this package at all if it can be handled by just setting lib (which we must do anyway)?

My solution was to add lib: [ "es2015", "dom" ] in my ts.config and I also removed this library since it wasn't needed when I added the lib entries.

If the owners of this package doesn't want to do anything with this. I suggest you to close this issue with a comment why and how to do it correctly so that everyone knows what to do.

@DrDanRyan typescript documentation says that using es5 as a target adds DOM,ES5,ScriptHost to libs. So this should not be needed.
@Narven when adding es2017 to your lib you don't need core-js typings anymore. I wonder why you don't get duplicate identifiers then.

I'm a bit confused why core-js typings suddenly depend on another set of libraries. That doesn't look like the right solution to me.

More Issues: