Microsoft/TypeScript

Precedence in parsing types

开放

#7,094 创建于 2016年2月16日

 (5 条评论) (0 个反应) (0 位负责人)TypeScript (13,395 个派生)batch import
DocsHelp Wanted

仓库指标

星标
 (108,860 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

It looks to me like this should parse, but it doesn't:

var x: number | (string)=>void;

It works with added parens:

var x: number | ((string)=>void);

But if the parser is not too hacky, then maybe it's easy to make the first work?

(FWIW, I ran into this in a rest argument, where it would be nice to avoid the extra parens in

function foo(...xs: (number | ()=>void)[]): void { }

)

贡献者指南