From a6068c0532e1164871edd0bf18533324da2dd2ff Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 24 May 2017 15:21:30 -0700 Subject: [PATCH] Temporary fix comments inside of flow type spread (#1716) This is breaking on fb code. While benjamn/ast-types#221 is getting merged in ast-type, we can add it in prettier so it fixes the issue. Fixes #1632 --- src/typescript-ast-nodes.js | 7 +++++++ .../flow_type_spread/__snapshots__/jsfmt.spec.js.snap | 10 ++++++++++ tests/flow_type_spread/comments.js | 2 ++ tests/flow_type_spread/jsfmt.spec.js | 1 + 4 files changed, 20 insertions(+) create mode 100644 tests/flow_type_spread/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/flow_type_spread/comments.js create mode 100644 tests/flow_type_spread/jsfmt.spec.js diff --git a/src/typescript-ast-nodes.js b/src/typescript-ast-nodes.js index 3e1571fd..cd9fedb1 100644 --- a/src/typescript-ast-nodes.js +++ b/src/typescript-ast-nodes.js @@ -8,6 +8,13 @@ module.exports = function(fork) { const or = types.Type.or; const defaults = fork.use(require("ast-types/lib/shared")).defaults; + // Putting it here while it's being merged upstream + // https://github.com/benjamn/ast-types/pull/221 + def("ObjectTypeSpreadProperty") + .bases("Node") + .build("argument") + .field("argument", def("Type")); + // Ambient def("TSAmbientVariableDefinition").bases("VariableDeclaration"); diff --git a/tests/flow_type_spread/__snapshots__/jsfmt.spec.js.snap b/tests/flow_type_spread/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 00000000..f3ab3121 --- /dev/null +++ b/tests/flow_type_spread/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`comments.js 1`] = ` +type X = {...Y/**/}; +type X = {/**/...Y}; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +type X = { ...Y /**/ }; +type X = { /**/ ...Y }; + +`; diff --git a/tests/flow_type_spread/comments.js b/tests/flow_type_spread/comments.js new file mode 100644 index 00000000..cbbce35b --- /dev/null +++ b/tests/flow_type_spread/comments.js @@ -0,0 +1,2 @@ +type X = {...Y/**/}; +type X = {/**/...Y}; diff --git a/tests/flow_type_spread/jsfmt.spec.js b/tests/flow_type_spread/jsfmt.spec.js new file mode 100644 index 00000000..1840e9d3 --- /dev/null +++ b/tests/flow_type_spread/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, null, ["babylon"]);