Merge pull request #45 from danharper/fix38

Print Flow types with no name (fixes #38)
master
James Long 2017-01-10 23:51:42 -05:00 committed by GitHub
commit 10a8cd9122
4 changed files with 15 additions and 2 deletions

View File

@ -1331,7 +1331,7 @@ function genericPrintNoParens(path, options, print) {
return concat([
path.call(print, "name"),
n.optional ? "?" : "",
": ",
n.name ? ": " : "",
path.call(print, "typeAnnotation")
]);
case "GenericTypeAnnotation":
@ -1421,7 +1421,7 @@ function genericPrintNoParens(path, options, print) {
variance,
"[",
path.call(print, "id"),
": ",
n.id ? ": " : "",
path.call(print, "key"),
"]: ",
path.call(print, "value")

View File

@ -0,0 +1,9 @@
exports[`test optional-type-name.js 1`] = `
"type Foo = (any) => string
type Bar = { [string]: number }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type Foo = (any) => string;
type Bar = { [string]: number };"
`;

View File

@ -0,0 +1 @@
run_spec(__dirname);

View File

@ -0,0 +1,3 @@
type Foo = (any) => string
type Bar = { [string]: number }