Skip to content

Design Meeting Notes, 2/2/2024 #57276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DanielRosenwasser opened this issue Feb 2, 2024 · 0 comments
Closed

Design Meeting Notes, 2/2/2024 #57276

DanielRosenwasser opened this issue Feb 2, 2024 · 0 comments
Labels
Design Notes Notes from our design meetings

Comments

@DanielRosenwasser
Copy link
Member

Order-Dependency with Contextual Typing and Discriminated Unions

#57231

  • Discriminated unions are really unions of objects that have discriminant properties.
  • We say that a property is considered a discriminant if its type differs in at least two constituents, and one of those constituents is a literal-like type.
  • For template string types, you need information about the contextual type before you can make any decision about the template literal itself.
    • So we can't get a narrowed contextual type.
    • End up not getting a more specific type for other properties, assignment fails.
  • In general, overlapping discriminant types is a bad idea.
  • A few options.
    • Do nothing.
    • Don't consider properties discriminants if one type subsumes the other.
      • Doesn't work.
    • Create a notion of "better" discriminants, discriminate on those first.
  • Why is it the case that we don't create literal types out of template string expressions wihtout a contextual types?
    • It was too breaky.
@DanielRosenwasser DanielRosenwasser added the Design Notes Notes from our design meetings label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Notes Notes from our design meetings
Projects
None yet
Development

No branches or pull requests

2 participants