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.import
is with dynamicimport()
and a top-levelawait
.import
in any module.process.getBuiltinModule(id)
.--experimental...
flag, patches the globalprocess
object to basically polyfill ingetBuiltinModule
.import.now
(synchronousimport
).weak
/optional
imports - might be attributes on the import.getBuiltInModule
function?import
conditions..cjs
module exportsrequire
or something similar?require(ESM)
require(ESM)
be backported to Node 20?Add
BuiltinIteratorReturn
type (part of addingTReturn
/TNext
toIterableIterator
)#58243
TReturn
/TNext
through theIterableIterator
type.TypeScriptSettings
Design Meeting Notes, 5/3/2024 #58429BuiltinIteratorReturn
intrinsic type alias.--noUncheckedIndexedAccess
.BuiltinIteratorReturn
isundefined
orany
depending on the option.BuiltinIteratorReturn
.BuiltinIteratorReturn
used as the default type argument forIterableIterator
etc.?--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?
Map
s.any
any
-noImplicitAny
?undefined
-strictNullChecks
?noUncheckedIndexedAccess
?noUncheckedIteratorResults
?catch
variables as well.The text was updated successfully, but these errors were encountered: