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
Intersections of undefined and object types get evaporated away.
typeFoo={x: string}|undefined;typeBar={y: string};typeFooAndBar=Foo&Bar;// ^? { x: string } & Bar// No `undefined` because `undefined & Bar` is `never`
Okay, what's the problem?
typeFoo={x: string}|undefined;typeBar={y: string};typeKF=keyofFoo;typeKB=keyofBar;typeK1=keyof(Foo&Bar);// ^? "x" | "y"typeK2=keyofFoo|keyofBar;// ^? "x"
Uh oh.
Could make the argument that keyof (T | undefined) should probably just be keyof T - if you have a type like keyof (T | undefined), being able to actually index into a T depends on actually being able to do something with the T itself.
You can already write (T | undefined)[keyof T] in type space without any issues. So the idea of (T | undefined)[keyof (T | undefined)] being allowed makes sense.
Are we sure we're not saving someone from a mistake?
Feels like as long as you're preventing the indexing in the value space, that's where the value is.
Seems reasonable, we'd like to experiment with that.
[[Revisiting - the getProp function actually doesn't make enough guarantees for us to do this safely.]]
Prologue directive to specify to Node what named exports a CommonJS provides.
Node can't do the same analyses that bundlers perform, so this directive is intended to help here.
Gives CJS modules a path forward for compat.
Maybe not too bad because we serialize __esModule markers.
For our emit, specifying these when given as inputs would "just work" because we preserve all prologue directives.
The fact that this is in a JavaScript file complicates things for us. We would need to see some sort of marker in the .d.ts file.
Or we would need to resolve the JavaScript file and scan prologue directives.
Apart from the complications, we are not a big fan of adding more and more and more and more to try to fix CJS/ESM interop. Every fix is another edge case for devs. It continues to complicate the options and configuration people need to manage.
The text was updated successfully, but these errors were encountered:
Ignoring
undefined
/null
types fed intokeyof
#51331
Intersections of undefined and object types get evaporated away.
Okay, what's the problem?
Uh oh.
Could make the argument that
keyof (T | undefined)
should probably just bekeyof T
- if you have a type likekeyof (T | undefined)
, being able to actually index into aT
depends on actually being able to do something with theT
itself.You can already write
(T | undefined)[keyof T]
in type space without any issues. So the idea of(T | undefined)[keyof (T | undefined)]
being allowed makes sense.Are we sure we're not saving someone from a mistake?
Seems reasonable, we'd like to experiment with that.
[[Revisiting - the
getProp
function actually doesn't make enough guarantees for us to do this safely.]]Node.js module interop changes
nodejs/node#50981
nodejs/node#50096
__esModule
markers..d.ts
file.The text was updated successfully, but these errors were encountered: