Microsoft/TypeScript

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

Aberta

#37.760 aberto em 2 de abr. de 2020

 (1 comentário) (0 reação) (0 responsável)TypeScript (13.395 forks)batch import
BugDomain: ParserHelp Wanted

Métricas do repositório

Stars
 (108.860 estrelas)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

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

Guia do colaborador