Js-lingui: Support comments inside JSX macros by ignoring empty jsx expressions

Created on 27 Apr 2020  路  2Comments  路  Source: lingui/js-lingui

Describe the bug
When using a <Trans> element with a nested element like {/* This is a comment */}, it complains of @lingui/macro: Property value of ObjectProperty expected node to be of a type ["Expression","PatternLike"] but instead got "JSXEmptyExpression" Learn more: https://www.npmjs.com/package/@lingui/macro

To Reproduce
Steps to reproduce the behavior, possibly with minimal code sample, e.g:

import { Trans } from "@lingui/macro"

export default function App() {
   return (<Trans>
    {/* TODO: Come up with a better translation than this */}
    This should be translated!
  </Trans>)
}

Expected behavior
The comment should be ignored completely, leaving just the "This should be translated!" text.

Additional context
Add any other context about the problem here.

  • jsLingui version 2.9.1
  • Babel version [email protected]
  • Your Babel config (e.g. .babelrc) or framework you use (Create React App, Meteor, etc.): Create React App
accepted 馃悶bug 馃摝 macro

All 2 comments

@ckknight Yeah, that's a good point! Willing to dive in and send a PR? If so, please use next branch as a base.

@tricoder42 yep, I'm on it.

Was this page helpful?
0 / 5 - 0 ratings