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

Generic syntax ambiguity is handled incorrectly #60874

Open
reverofevil opened this issue Dec 29, 2024 · 1 comment
Open

Generic syntax ambiguity is handled incorrectly #60874

reverofevil opened this issue Dec 29, 2024 · 1 comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@reverofevil
Copy link

πŸ”Ž Search Terms

generic syntax ambiguity

πŸ•— Version & Regression Information

  • I was unable to test this on prior versions because there is no online tooling for it

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAhjAvDAjAGhgIyTATB4HAZgwBMcAWDAUxwFYBuAKFEhABtqA6dkAcwAUCADxYMAwgD4YA8gDIY1AJQrmQA

πŸ’» Code

const a = 1, b = 2, c = 3, d = 4, e = 5;
console.log(a < b, (c > (d & e)));

πŸ™ Actual behavior

This expression is not callable.

πŸ™‚ Expected behavior

true false

Additional information about the issue

While there might be some justification for why

const a = 1, b = 2, c = 3, d = 4, e = 5;
console.log(a < b, c > (d & e));

doesn't work as it did in JS, in the provided example there isn't even any disambiguity.

@robpalme
Copy link

The general Relational Expression ambiguity is a long-standing known issue. But as you mention, this is a more specific case where there's no ambiguity given that < b, (c > cannot be parsed as type arguments.

Whilst the TypeScript parser deems < b, (c > to be erasable types, most other mainstream parsers do not. These parsers correctly preserve the original JS semantics when attempting to parse as TS:

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels Jan 2, 2025
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

3 participants