-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Description
Optional chaining update and feedback
https://github.com/tc39/proposal-optional-chaining/
tc39/proposal-optional-chaining#59
- [[Review of feature, short-circuiting behavior, use-cases for optional call, nullish vs. uncallable behavior for optional call]]
Issues with narrowing unions by union types
- Basically if you have a union type, narrowing down doesn't work if you are narrowing from unions with unions where some constituents of a union are subtypes of the other union.
- For example, narrowing
string | number
to"hello" | number
. - You end up with intersections today.
- For example, narrowing
Cat & Mortgage
seems unlikely, but it's indistinguishable fromMixinA & MixinB
.- Is that really common?
- It happens in the compiler.
- Whenever you have a non-discriminated union, things go wrong.
hasType
exhibits some issues here, and the new behavior catches this.- But the new behavior explodes in types, is usually not the intent for many cases, and creates impossible branded literal types.
- Why do we even use intersection types - can we do somethig more precise from the original example?
- Necessary to work with object types.
- A lot of user intent seems to indicate people think of types as closed.
- Keeps coming up.
- On a meta level, we need to think about this at a more holistic level, see what the interplay would be between negated types, closed types, etc.
- Conclusion: we don't think we have any idea of how to cleanly solve the current problem. No action chosen. We may
AnyhowStep
Metadata
Metadata
Assignees
Labels
Design NotesNotes from our design meetingsNotes from our design meetings