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
[ts] treat single type param with a constraint as unambiguous #15436
[ts] treat single type param with a constraint as unambiguous #15436
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53945/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -1,2 +1,3 @@ | |||
<T,>() => 1; | |||
<T,>(x) => 1; | |||
<T extends unknown>(x) => 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add
<T = unknown,>(x) => 1
It should be unambiguous because of the trailing comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -1,2 +1,3 @@ | |||
<T>() => 1; | |||
<T>(x) => 1; | |||
<T = unknown>(x) => 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this ambiguous?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, had the same doubt - i dont know. It’s treated as ambigous by TS though 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds like a bug, but yeah we should match their behavior.
Fixes #1, Fixes #2
This matches the TS behavior. I verified that constraints make this unambiguous (but defaults don't)