question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript's lib includes "esnext"

See original GitHub issue

Hello, I am confused by "esnext" in lib for TypeScript.

"lib": [
	"dom",
	"dom.iterable",
	"esnext"
],

Does this mean I can use e.g. flatMap? Who provides the polyfill?

Background: I am in the process of migration from CRA-TS to CRA2. Previously we implemented our own flatMap and used es6 as library.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ianschmitzcommented, Apr 13, 2019

The behavior of lib is no different than using the TypeScript compiler by itself. It only specifies which APIs that you “claim” will be available at runtime. This means you can use things like Map, Set, Promise, etc and TypeScript will know what those APIs are. You can customize lib to suit your project.

lib doesn’t provide any polyfills. You will need to do that separately depending on the APIs you’re using and your target browsers. As a side note the TypeScript compiler isn’t used in CRA to compile code, and is only used for type checking.

0reactions
alamothecommented, Apr 13, 2019

Thanks for detailed explanation! Back to es6 for me… the future is still not there 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Option: lib - TypeScript
lib. TypeScript includes a default set of type definitions for built-in JS APIs (like ... ESNext, Additional APIs available in ESNext - This...
Read more >
Using ES6 and ESNext with TypeScript - Egghead.io
That said it is super easy to configure TypeScript to use ES6 or ESNext using the lib option. We also cover how to...
Read more >
Using 'ESNext' as a TypeScript lib option screws up the react ...
This is really interesting question. From my understanding, the issue isn't from esnext lib. The real issue is from missing DOM library ......
Read more >
Compiler Options - Microsoft Open Source
The value ESNext refers to whatever the highest version TypeScript supports at the time is. This setting should be used with caution, since...
Read more >
"Enable library es2021.promise in tsconfig.json" quickfix adds ...
TSError: ⨯ Unable to compile TypeScript: error TS6046: Argument for '--lib' ... 'esnext.bigi nt', 'esnext.string', 'esnext.promise', 'esnext.weakref'. at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found