fix typeParameters printing TSFunctionType w/o breaking flow (#1397)

master
Danny Arnold 2017-04-24 02:33:00 +02:00 committed by Christopher Chedeau
parent 6f0cc31fdb
commit 689e520abe
1 changed files with 6 additions and 2 deletions

View File

@ -1631,13 +1631,17 @@ function genericPrintNoParens(path, options, print, args) {
if (needsParens) {
parts.push("(");
}
if (n.typeParameters && n.typeParameters.length) {
// With TypeScript `typeParameters` is an array of `TSTypeParameter` and
// with flow they are one `TypeParameterDeclaration` node.
if (n.type === 'TSFunctionType' && n.typeParameters) {
parts.push(
"<",
join(", ", path.map(print, "typeParameters")),
">"
)
} else {
parts.push(path.call(print, "typeParameters"));
}
parts.push(printFunctionParams(path, print, options));