Microsoft/TypeScript

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

Open

#37,760 创建于 2020年4月2日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: ParserHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

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

贡献者指南