We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 Version: nightly (2.2.0)
Code
function id<T>(x: T): T { return x; } function stringId(x: string): string { return x; } function numberId(x: number): number { return x; } // OK: ((x: string) => string) | ((x: number) => number) const f = true ? numberId : stringId; // Actual: <T>(x: T) => T // Expected: (x: string) => string const g = true ? id : stringId;
Expected behavior: Union between a function and a generic function should yield the most specific type, not the most general one.
The text was updated successfully, but these errors were encountered:
I agree with the expected behavior. I also wonder if it would be reasonable to not collapse the union and keep both constituents.
Sorry, something went wrong.
Fixed by #16368
No branches or pull requests
TypeScript Version: nightly (2.2.0)
Code
Expected behavior:
Union between a function and a generic function should yield the most specific type, not the most general one.
The text was updated successfully, but these errors were encountered: