Skip to content

Commit

Permalink
Fix <this.Component /> (#2472)
Browse files Browse the repository at this point in the history
This is a workaround while waiting on
eslint/typescript-eslint-parser#337.

Fixes #2471
  • Loading branch information
backus authored and azz committed Jul 13, 2017
1 parent ef91e28 commit 1691b85
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(":", [
Expand Down
2 changes: 2 additions & 0 deletions tests/typescript_tsx/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ const MyCoolThing = ({ thingo }) => <li>{thingo}</li>;
exports[`this.tsx 1`] = `
<this.state.Component />;
<this.Component />;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<this.state.Component />;
<this.Component />;
`;
1 change: 1 addition & 0 deletions tests/typescript_tsx/this.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<this.state.Component />;
<this.Component />;

0 comments on commit 1691b85

Please sign in to comment.