From bcc3eb92725a56f1e0166e1097fd525e9f9eeed2 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 23 May 2017 13:14:30 -0700 Subject: [PATCH] Add TSTupleType to ast-types (#1685) Otherwise this throws --- src/typescript-ast-nodes.js | 7 ++++++ .../__snapshots__/jsfmt.spec.js.snap | 23 +++++++++++++++++++ tests/typescript_tuple/jsfmt.spec.js | 1 + tests/typescript_tuple/tuple.ts | 9 ++++++++ 4 files changed, 40 insertions(+) create mode 100644 tests/typescript_tuple/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/typescript_tuple/jsfmt.spec.js create mode 100644 tests/typescript_tuple/tuple.ts diff --git a/src/typescript-ast-nodes.js b/src/typescript-ast-nodes.js index 4763e70d3..72eedd8b6 100644 --- a/src/typescript-ast-nodes.js +++ b/src/typescript-ast-nodes.js @@ -26,6 +26,13 @@ module.exports = function(fork) { def("TSType").bases("Node"); + def("TSTupleType") + .build("elementTypes") + .field("elementTypes", [def("TSType")]) + .bases("Node"); + + def("TSArrayType").bases("Node"); + def("TypeElement").bases("Node"); def("TSSignature") diff --git a/tests/typescript_tuple/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_tuple/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..2314c77a5 --- /dev/null +++ b/tests/typescript_tuple/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,23 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`tuple.ts 1`] = ` + +export type SCMRawResource = [ + number /*handle*/, + string /*resourceUri*/, + modes.Command /*command*/, + string[] /*icons: light, dark*/, + boolean /*strike through*/, + boolean /*faded*/ +]; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +export type SCMRawResource = [ + number /*handle*/, + string /*resourceUri*/, + modes.Command /*command*/, + string[] /*icons: light, dark*/, + boolean /*strike through*/, + boolean /*faded*/ +]; + +`; diff --git a/tests/typescript_tuple/jsfmt.spec.js b/tests/typescript_tuple/jsfmt.spec.js new file mode 100644 index 000000000..bc085c48c --- /dev/null +++ b/tests/typescript_tuple/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript_tuple/tuple.ts b/tests/typescript_tuple/tuple.ts new file mode 100644 index 000000000..3a48e5f94 --- /dev/null +++ b/tests/typescript_tuple/tuple.ts @@ -0,0 +1,9 @@ + +export type SCMRawResource = [ + number /*handle*/, + string /*resourceUri*/, + modes.Command /*command*/, + string[] /*icons: light, dark*/, + boolean /*strike through*/, + boolean /*faded*/ +];