From f8ff7e5cd2f6e0b6fa6ea09fc5647170e3dad8af Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Tue, 23 May 2017 16:31:01 -0700 Subject: [PATCH] Add TSArrayType to ast-types (#1690) --- src/typescript-ast-nodes.js | 5 ++++- .../__snapshots__/jsfmt.spec.js.snap | 22 +++++++++++++++++++ tests/typescript_array/comment.js | 8 +++++++ tests/typescript_array/jsfmt.spec.js | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/typescript_array/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/typescript_array/comment.js create mode 100644 tests/typescript_array/jsfmt.spec.js diff --git a/src/typescript-ast-nodes.js b/src/typescript-ast-nodes.js index 72eedd8b..da2a8305 100644 --- a/src/typescript-ast-nodes.js +++ b/src/typescript-ast-nodes.js @@ -31,7 +31,10 @@ module.exports = function(fork) { .field("elementTypes", [def("TSType")]) .bases("Node"); - def("TSArrayType").bases("Node"); + def("TSArrayType") + .build("elementType") + .field("elementType", def("TSType")) + .bases("Node"); def("TypeElement").bases("Node"); diff --git a/tests/typescript_array/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_array/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 00000000..b971a247 --- /dev/null +++ b/tests/typescript_array/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,22 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`comment.js 1`] = ` +export class ViewTokensChangedEvent { + public readonly ranges: { + /** + * Start line number of range + */ + readonly fromLineNumber: number; + }[]; +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +export class ViewTokensChangedEvent { + public ranges: { + /** + * Start line number of range + */ + readonly fromLineNumber: number + }[]; +} + +`; diff --git a/tests/typescript_array/comment.js b/tests/typescript_array/comment.js new file mode 100644 index 00000000..fc83357c --- /dev/null +++ b/tests/typescript_array/comment.js @@ -0,0 +1,8 @@ +export class ViewTokensChangedEvent { + public readonly ranges: { + /** + * Start line number of range + */ + readonly fromLineNumber: number; + }[]; +} diff --git a/tests/typescript_array/jsfmt.spec.js b/tests/typescript_array/jsfmt.spec.js new file mode 100644 index 00000000..bc085c48 --- /dev/null +++ b/tests/typescript_array/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" });