Skip to content

Parsing issue for call expression with type arguments following left-shift #37760

Open

Description

@dcodeIO

TypeScript Version: 3.8.3

Search Terms: left shift, type parameter

Expected behavior: Syntax highlighting stays intact.

Actual behavior: Syntax highlighting breaks, even with ts-ignore.

Code

function alignof<T>(): number {
  return 1;
}

// works
function foo<T>(): number {
  return 1 >> alignof<T[]>();
}

// breaks
function bar<T>(): number {
  return 1 << alignof<T[]>();
}

// still breaks, does not ignore
function baz<T>(): number {
  // @ts-ignore
  return 1 << alignof<T[]>();
}

Looks like a rescan issue on potentially ambiguous < tokens, attempting to interpret as 1 < <type>.

Playground Link: Provided

Activity

  1. changed the title [-]Syntax highlighting issue on less-than token[/-] [+]Parsing issue for call expression with type arguments following left-shift[/+] on Apr 2, 2020
  2. RyanCavanaugh commented on Apr 3, 2020

    @RyanCavanaugh
    Member

    At an asbolute bare minimum, parenthesizing the right operand ought to work around the problem.

    FYI ts-ignore isn't capable of causing syntax errors to not happen

  3. added
    Needs Human ReviewThis issue has a backlog check awaiting maintainer review.
    and removed
    Needs Human ReviewThis issue has a backlog check awaiting maintainer review.
    on Sep 4, 2026
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 correctlyHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions