diff --git a/src/printer.js b/src/printer.js index 1a7acc6e3..cbbd1168b 100644 --- a/src/printer.js +++ b/src/printer.js @@ -775,7 +775,7 @@ function genericPrintNoParens(path, options, print, args) { path.call(print, "name"), printTypeParameters(path, options, print, "typeParameters"), " " - ); + ); } if (n.heritageClauses) { prefix.push( @@ -2149,7 +2149,7 @@ function genericPrintNoParens(path, options, print, args) { if (n.type !== "TSCallSignature") { parts.push("new "); } - var isType = n.type === "TSConstructorType"; + var isType = n.type === "TSConstructorType"; parts.push( printTypeParameters(path, options, print, "typeParameters"), "(", @@ -3063,6 +3063,7 @@ function printMemberLookup(path, options, print) { } if ( + !n.property || (n.property.type === "Literal" && typeof n.property.value === "number") || n.property.type === "NumericLiteral" ) { diff --git a/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..ad6a1e8bb --- /dev/null +++ b/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`badArrayIndex.ts 1`] = ` +var results = number[]; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +var results = number[]; + +`; diff --git a/tests/typescript/compiler/badArrayIndex.ts b/tests/typescript/compiler/badArrayIndex.ts new file mode 100644 index 000000000..110bf52e9 --- /dev/null +++ b/tests/typescript/compiler/badArrayIndex.ts @@ -0,0 +1 @@ +var results = number[]; diff --git a/tests/typescript/compiler/jsfmt.spec.js b/tests/typescript/compiler/jsfmt.spec.js new file mode 100644 index 000000000..bc085c48c --- /dev/null +++ b/tests/typescript/compiler/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" });