Skip to content

Design Meeting Notes, 6/21/2019 #32158

Closed
Closed
@DanielRosenwasser

Description

@DanielRosenwasser

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

#31156
#31206

  • 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.
  • Cat & Mortgage seems unlikely, but it's indistinguishable from MixinA & 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design NotesNotes from our design meetings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions