Microsoft/TypeScript

Precedence in parsing types

Open

#7,094 建立於 2016年2月16日

在 GitHub 查看
 (5 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
DocsHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 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 { }

)

貢獻者指南