Skip to content

Generic syntax ambiguity is handled incorrectlyΒ #60874

Open

Description

@reverofevil

πŸ”Ž 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.

Activity

  1. robpalme commented on Dec 30, 2024

    @robpalme

    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:

  2. magic-akari commented on Nov 15, 2026

    @magic-akari
    Contributor

    I’m working on a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: ParserThe parser didn't handle the syntax correctly

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions