diff --git a/src/printer.js b/src/printer.js index 7b41c06a99ae..2027c7500d35 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1596,6 +1596,11 @@ function genericPrintNoParens(path, options, print, args) { return concat(parts); case "JSXIdentifier": + // Can be removed when this is fixed: + // https://github.com/eslint/typescript-eslint-parser/issues/337 + if (!n.name) { + return "this"; + } return "" + n.name; case "JSXNamespacedName": return join(":", [ diff --git a/tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap index b8d82a939fe9..be0cb27565f3 100644 --- a/tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap @@ -52,7 +52,9 @@ const MyCoolThing = ({ thingo }) => exports[`this.tsx 1`] = ` ; +; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; +; `; diff --git a/tests/typescript_tsx/this.tsx b/tests/typescript_tsx/this.tsx index f3bd61bc75f1..a9ab134d4b48 100644 --- a/tests/typescript_tsx/this.tsx +++ b/tests/typescript_tsx/this.tsx @@ -1 +1,2 @@ ; +;