-
Notifications
You must be signed in to change notification settings - Fork 12.8k
TS 2.4.1 flags legal code as invalid? #17000
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
Comments
It isn't technically valid code. At this point |
@kitsonk There is an overload for each of those types, but AFAICT the parser wants an overload that accepts a union of both types. Which makes sense, because the two overloads return different types, and so it's ambiguous as to what the return type should be. I've previously argued that overloads with ambiguous return values should return a union of their return types, but the TS team did not agree. |
Which overload matches |
No overload matches a union of both, which is the issue. My argument in the linked issue was that those two overloads together imply an overload of |
@errorx666 you are correct, because it was named, I wasn't doing the mental gymnastics... the reason it used to be valid was because of weak types but yes, now, yes... the other problem. There is also this pattern: public parse(value: Config.ProblemPattern | Config.MultiLineProblemPattern | Config.NamedProblemPattern | Config.NamedMultiLineProblemPattern): any; Which would imply that |
Duplicate #1805 |
TypeScript Version: 2.4.1
Code
Expected behavior:
No error message
Actual behavior:
Flags an error on line 73
The text was updated successfully, but these errors were encountered: