diff --git a/src/printer.js b/src/printer.js index d440df1d3..71e96ec6c 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1974,6 +1974,11 @@ function genericPrintNoParens(path, options, print, args) { ") => ", path.call(print, "typeAnnotation"), ]) + case "TSTypeOperator": + return concat([ + "keyof ", + path.call(print, "typeAnnotation") + ]) // TODO case "ClassHeritage": // TODO diff --git a/tests/typescript/conformance/types/typeOperator/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/types/typeOperator/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..c5004ade7 --- /dev/null +++ b/tests/typescript/conformance/types/typeOperator/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`typeOperator.ts 1`] = ` +let a: (keyof T)[] = ["a", "b"]; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +let a: (keyof T)[] = ["a", "b"]; + +`; diff --git a/tests/typescript/conformance/types/typeOperator/jsfmt.spec.js b/tests/typescript/conformance/types/typeOperator/jsfmt.spec.js new file mode 100644 index 000000000..bc085c48c --- /dev/null +++ b/tests/typescript/conformance/types/typeOperator/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/typeOperator/typeOperator.ts b/tests/typescript/conformance/types/typeOperator/typeOperator.ts new file mode 100644 index 000000000..36813dc2f --- /dev/null +++ b/tests/typescript/conformance/types/typeOperator/typeOperator.ts @@ -0,0 +1 @@ +let a: (keyof T)[] = ["a", "b"];