Microsoft/TypeScript

Precedence in parsing types

Open

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

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

描述

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 { }

)

貢獻者指南

Precedence in parsing types · Microsoft/TypeScript#7094 | Good First Issue