fix: don't write ': ' token when name is null (#7769)

This commit is contained in:
Yosuke Kurami 2018-04-22 00:34:24 +09:00 committed by Henry Zhu
parent b0e1e84471
commit 1f97b91655
3 changed files with 8 additions and 3 deletions

View File

@ -198,8 +198,10 @@ export function FunctionTypeAnnotation(node: Object, parent: Object) {
export function FunctionTypeParam(node: Object) { export function FunctionTypeParam(node: Object) {
this.print(node.name, node); this.print(node.name, node);
if (node.optional) this.token("?"); if (node.optional) this.token("?");
this.token(":"); if (node.name) {
this.space(); this.token(":");
this.space();
}
this.print(node.typeAnnotation, node); this.print(node.typeAnnotation, node);
} }

View File

@ -12,3 +12,5 @@ type overloads =
& ((x: string) => number) & ((x: string) => number)
& ((x: number) => string) & ((x: number) => string)
; ;
type func = string => string;

View File

@ -8,3 +8,4 @@ type union = {
type: "B" type: "B"
}; };
type overloads = (x: string) => number & (x: number) => string; type overloads = (x: string) => number & (x: number) => string;
type func = (string) => string;