Skip to content

T should be assignable to A extends B ? C : D if it is assignable to both C and D #26933

Closed
@mattmccutchen

Description

@mattmccutchen

Search Terms

conditional assignable both

Suggestion

A type T should be assignable to A extends B ? C : D if it is assignable to both C and D. Previously mentioned here and here, but it doesn't appear that anyone ever filed an issue to track this.

It's unclear what to do if C references infer type parameters, but even an assignability rule that works only when C does not reference infer type parameters would be useful.

If the conditional type is distributive, then the rule only applies if A is known not to be never.

Use Cases

See this comment for one.

Examples

TBD

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript / JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. new expression-level syntax)

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueInvestigatingIs in active investigationSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions