Microsoft/TypeScript

Precedence in parsing types

Aberta

#7.094 aberto em 16 de fev. de 2016

 (5 comentários) (0 reação) (0 responsável)TypeScript (13.395 forks)batch import
DocsHelp Wanted

Métricas do repositório

Stars
 (108.860 estrelas)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

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

)

Guia do colaborador