Skip to content
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

TypeScript: infer extends within union fails to compile if it's at the top level #3574

Closed
satohshi opened this issue Jan 2, 2024 · 0 comments

Comments

@satohshi
Copy link

satohshi commented Jan 2, 2024

Issue

The following code fails to compile with error Expected "?" but found end of file:

type InferUnion<T> = T extends { a: infer U extends number } | infer U extends number
    ? U
    : never

The issue seems to be with infer U extends at the top level of a union, as the following compiles fine:

type InferUnion<T> = T extends { a: infer U extends number } | { b: infer U extends number }
    ? U
    : never

Reproduction

esbuild playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant