Microsoft/TypeScript

Precedence in parsing types

Ouverte

#7 094 ouverte le 16 févr. 2016

 (5 commentaires) (0 réaction) (0 personne assignée)TypeScript (13 395 forks)batch import
DocsHelp Wanted

Métriques du dépôt

Stars
 (108 860 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

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

)

Guide contributeur