You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have an example version of Node which just turns the new --experimental... flag, patches the global process object to basically polyfill in getBuiltinModule.
And it works!
There's also an idea for import.now (synchronous import).
Also ideas for weak/optional imports - might be attributes on the import.
Do we actually need that getBuiltInModule function?
You can use import conditions.
Can you also just create a .cjs module exports require or something similar?
Another idea: ship ESM, have different API entry-points.
We can play with all these...
But you really want people to be able to create a single file to make things convenient (or have a continuous ESM module graph at the least)
Why is ESM good?
Allows us to split shared parts of the TypeScript package without incurring a performance penalty.
Also, people can't tree-shake as well against us - static analysis can only go so far.
Also lets us use ESM utilities more seamlessly.
What's the timeline on this?
Feels like the Node devs (and ecosystem) are really excited about require(ESM)
It is worth asking: could require(ESM) be backported to Node 20?
TypeScript currently supports Node 14...
We could evaluate our policy on this.
So it all depends on us and on Node as well.
How far back it gets backported (if at all).
How soon we're willing to jump our minimum supported Node version.
Add BuiltinIteratorReturn type (part of adding TReturn/TNext to IterableIterator)
TypeScript as ESM (one day!)
require("some-esm-module"), and that hits a top-levelawait, then it fails.require()s.importis with dynamicimport()and a top-levelawait.importin any module.process.getBuiltinModule(id).--experimental...flag, patches the globalprocessobject to basically polyfill ingetBuiltinModule.import.now(synchronousimport).weak/optionalimports - might be attributes on the import.getBuiltInModulefunction?importconditions..cjsmodule exportsrequireor something similar?require(ESM)require(ESM)be backported to Node 20?Add
BuiltinIteratorReturntype (part of addingTReturn/TNexttoIterableIterator)#58243
TReturn/TNextthrough theIterableIteratortype.TypeScriptSettingsDesign Meeting Notes, 5/3/2024 #58429BuiltinIteratorReturnintrinsic type alias.--noUncheckedIndexedAccess.BuiltinIteratorReturnisundefinedoranydepending on the option.BuiltinIteratorReturn.BuiltinIteratorReturnused as the default type argument forIterableIteratoretc.?--noUncheckedIndexedAccess. We get it, but it would be confusing.If you write
you get an error if you don't provide that postfix
!.Why special-case here?
Maps.anyany-noImplicitAny?undefined-strictNullChecks?noUncheckedIndexedAccess?noUncheckedIteratorResults?catchvariables as well.