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
Incorrect union of function return type, function incorrect union
v4.8.4 - This is the behaviour in every version I tried, and I reviewed the FAQ for entries about functions and unions
v4.8.4
Playground link with relevant code
output is { w: number; x: string; }
output
{ w: number; x: string; }
output is { w: number; x: string; } | { w: number; x: string; y: boolean; z: symbol}
{ w: number; x: string; } | { w: number; x: string; y: boolean; z: symbol}
The text was updated successfully, but these errors were encountered:
This is due to subtype reduction: bar’s return type is a subtype of foo’s, so it’s eliminated from the union. This is by design, e.g. see #49710
bar
foo
Sorry, something went wrong.
Closest thing to a canonical duplicate is probably #46449
Thanks for the quick response. Is there a document I can read that explains the reasoning for the design decision; I'm curious.
No official documentation I could find, but here’s the original PR that implemented it: #4537
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
Bug Report
🔎 Search Terms
Incorrect union of function return type, function incorrect union
🕗 Version & Regression Information
v4.8.4
- This is the behaviour in every version I tried, and I reviewed the FAQ for entries about functions and unions⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
output
is{ w: number; x: string; }
🙂 Expected behavior
output
is{ w: number; x: string; } | { w: number; x: string; y: boolean; z: symbol}
The text was updated successfully, but these errors were encountered: