Skip to content

Commit

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

Fixes prettier#2471
  • Loading branch information
backus committed Jul 13, 2017
1 parent 4131893 commit 6a2ef80
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 @@ -52,7 +52,9 @@ const MyCoolThing = ({ thingo }) =>
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 6a2ef80

Please sign in to comment.