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

[ts] treat single type param with a constraint as unambiguous #15436

Merged

Conversation

Andarist
Copy link
Member

@Andarist Andarist commented Feb 17, 2023

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix? x
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

This matches the TS behavior. I verified that constraints make this unambiguous (but defaults don't)

@babel-bot
Copy link
Collaborator

babel-bot commented Feb 17, 2023

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53945/

Copy link
Contributor

@JLHwung JLHwung left a 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;
Copy link
Contributor

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.

Copy link
Member Author

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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this ambiguous?

Copy link
Member Author

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 🤷‍♂️

Copy link
Member

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.

@nicolo-ribaudo nicolo-ribaudo changed the title fix: treat single TS type param with a constraint as unambiguous [ts] treat single type param with a constraint as unambiguous Feb 18, 2023
@nicolo-ribaudo nicolo-ribaudo merged commit 9be2c7f into main Feb 18, 2023
@nicolo-ribaudo nicolo-ribaudo deleted the fix/disallowAmbiguousJSXLike-allow-with-constraint branch February 18, 2023 11:45
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants