diff --git a/src/printer.js b/src/printer.js index 094ffd2b6..ba5dfa5b9 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1953,6 +1953,16 @@ function genericPrintNoParens(path, options, print, args) { ]); case "TSFirstTypeNode": return concat([n.parameterName.name, " is ", path.call(print, "typeAnnotation")]) + case "TSNeverKeyword": + return "never"; + case "TSUndefinedKeyword": + return "undefined"; + case "TSSymbolKeyword": + return "symbol"; + case "TSNonNullExpression": + return concat([path.call(print, "expression"), "!"]); + case "TSThisType": + return "this"; // TODO case "ClassHeritage": // TODO diff --git a/tests/typescript/conformance/types/never/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/types/never/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..bb10ef59d --- /dev/null +++ b/tests/typescript/conformance/types/never/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`never.ts 1`] = ` +var x: never +var x: never | string +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +var x: never; +var x: never | string; + +`; diff --git a/tests/typescript/conformance/types/never/jsfmt.spec.js b/tests/typescript/conformance/types/never/jsfmt.spec.js new file mode 100644 index 000000000..bc085c48c --- /dev/null +++ b/tests/typescript/conformance/types/never/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/never/never.ts b/tests/typescript/conformance/types/never/never.ts new file mode 100644 index 000000000..cd97d8f61 --- /dev/null +++ b/tests/typescript/conformance/types/never/never.ts @@ -0,0 +1,2 @@ +var x: never +var x: never | string diff --git a/tests/typescript/conformance/types/nonNullExpression/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/types/nonNullExpression/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..ccff87cac --- /dev/null +++ b/tests/typescript/conformance/types/nonNullExpression/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`nonNullExpression.ts 1`] = ` +var xx = (xx!, xx); +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +var xx = (xx!, xx); + +`; diff --git a/tests/typescript/conformance/types/nonNullExpression/jsfmt.spec.js b/tests/typescript/conformance/types/nonNullExpression/jsfmt.spec.js new file mode 100644 index 000000000..bc085c48c --- /dev/null +++ b/tests/typescript/conformance/types/nonNullExpression/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/nonNullExpression/nonNullExpression.ts b/tests/typescript/conformance/types/nonNullExpression/nonNullExpression.ts new file mode 100644 index 000000000..ce77f5e42 --- /dev/null +++ b/tests/typescript/conformance/types/nonNullExpression/nonNullExpression.ts @@ -0,0 +1 @@ +var xx = (xx!, xx); diff --git a/tests/typescript/conformance/types/symbol/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/types/symbol/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..8840bd5da --- /dev/null +++ b/tests/typescript/conformance/types/symbol/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`symbol.ts 1`] = ` +var x: symbol +var x: symbol | string +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +var x: symbol; +var x: symbol | string; + +`; diff --git a/tests/typescript/conformance/types/symbol/jsfmt.spec.js b/tests/typescript/conformance/types/symbol/jsfmt.spec.js new file mode 100644 index 000000000..bc085c48c --- /dev/null +++ b/tests/typescript/conformance/types/symbol/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/symbol/symbol.ts b/tests/typescript/conformance/types/symbol/symbol.ts new file mode 100644 index 000000000..3f4919024 --- /dev/null +++ b/tests/typescript/conformance/types/symbol/symbol.ts @@ -0,0 +1,2 @@ +var x: symbol +var x: symbol | string diff --git a/tests/typescript/conformance/types/thisType/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/types/thisType/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..209d0952b --- /dev/null +++ b/tests/typescript/conformance/types/thisType/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,12 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`thisType.ts 1`] = ` +declare class MyArray extends Array { + sort(compareFn?: (a: T, b: T) => number): this; +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +class MyArray extends Array { + sort(compareFn?: (a: T, b: T) => number): this +} + +`; diff --git a/tests/typescript/conformance/types/thisType/jsfmt.spec.js b/tests/typescript/conformance/types/thisType/jsfmt.spec.js new file mode 100644 index 000000000..bc085c48c --- /dev/null +++ b/tests/typescript/conformance/types/thisType/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/thisType/thisType.ts b/tests/typescript/conformance/types/thisType/thisType.ts new file mode 100644 index 000000000..490c1bae6 --- /dev/null +++ b/tests/typescript/conformance/types/thisType/thisType.ts @@ -0,0 +1,3 @@ +declare class MyArray extends Array { + sort(compareFn?: (a: T, b: T) => number): this; +} diff --git a/tests/typescript/conformance/types/undefined/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/types/undefined/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..23d4500f1 --- /dev/null +++ b/tests/typescript/conformance/types/undefined/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,10 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`undefined.ts 1`] = ` +var x: undefined +var x: undefined | string +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +var x: undefined; +var x: undefined | string; + +`; diff --git a/tests/typescript/conformance/types/undefined/jsfmt.spec.js b/tests/typescript/conformance/types/undefined/jsfmt.spec.js new file mode 100644 index 000000000..bc085c48c --- /dev/null +++ b/tests/typescript/conformance/types/undefined/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/undefined/undefined.ts b/tests/typescript/conformance/types/undefined/undefined.ts new file mode 100644 index 000000000..fff28da3d --- /dev/null +++ b/tests/typescript/conformance/types/undefined/undefined.ts @@ -0,0 +1,2 @@ +var x: undefined +var x: undefined | string