Microsoft/TypeScript

Precedence in parsing types

Open

#7,094 opened on 2016年2月16日

GitHub で見る
 (5 comments) (0 reactions) (0 assignees)TypeScript (6,726 forks)batch import
DocsHelp Wanted

Repository metrics

Stars
 (48,455 stars)
PR merge metrics
 (平均マージ 6d 17h) (30d で 9 merged PRs)

説明

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

)

コントリビューターガイド