diff --git a/src/printer.js b/src/printer.js index 75c8351d0f22..697b73da649c 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1510,12 +1510,9 @@ 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/257 - if (n.object && n.property) { - return join(".", [ - path.call(print, "object"), - path.call(print, "property") - ]); + // https://github.com/eslint/typescript-eslint-parser/issues/307 + if (!n.name) { + return "this"; } return "" + n.name; case "JSXNamespacedName": diff --git a/tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap index 18af0d59fd18..dcb1db90bed3 100644 --- a/tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap @@ -37,3 +37,10 @@ const MyCoolList = ({ things }) => const MyCoolThing = ({ thingo }) =>
  • {thingo}
  • ; `; + +exports[`this.tsx 1`] = ` +; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +; + +`; diff --git a/tests/typescript_tsx/this.tsx b/tests/typescript_tsx/this.tsx new file mode 100644 index 000000000000..f3bd61bc75f1 --- /dev/null +++ b/tests/typescript_tsx/this.tsx @@ -0,0 +1 @@ +;