From 0e35d3758aeb9ea62b141ccde352092f2e6ec567 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Fri, 2 Jun 2017 14:27:27 -0700 Subject: [PATCH] Fix (#1886) Would be nice to get it properly handled in https://github.com/eslint/typescript-eslint-parser/issues/307 Fixes #1877 --- src/printer.js | 9 +++------ tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap | 7 +++++++ tests/typescript_tsx/this.tsx | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 tests/typescript_tsx/this.tsx diff --git a/src/printer.js b/src/printer.js index a57768a9..d28ab891 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 18af0d59..dcb1db90 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 00000000..f3bd61bc --- /dev/null +++ b/tests/typescript_tsx/this.tsx @@ -0,0 +1 @@ +;