Code Monkey home page Code Monkey logo

Comments (4)

thekip avatar thekip commented on June 9, 2024

It's because you have typescript plugin before babel plugin. The lingui macro is looking for Trans JSX nodes in the AST, however after typescript plugin they are already transpiled to js and could not be matched and picked up by macro.

There are few possible solutiuons:

  • drop typescript and use only babel (for typescript transpiling as well)
  • If dropping typescript is not possible (for example because of using legacy decorators + emitDecoratorMetdata?) you can set "jsx": "preserve", in tsconfig.json so JSX statements would be passed as-is to the babel.
  • Consider moving to SWC which is not only faster, but also supports emitDecoratorMetdata and could be used as drop-in replacement for tsc

from js-lingui.

simlmx avatar simlmx commented on June 9, 2024

Thanks for the quick reply!

I see this makes sense. Indeed using "jsx": "preserve" and adding the @babel/preset-react" preset made it work.

Should there be anything in the doc about this? There is a Typescript section but it reads:

You should not need to do anything to get type support working.

from js-lingui.

thekip avatar thekip commented on June 9, 2024

You should not need to do anything to get type support working.

type support

For macro support docs says that you need either babel or SWC compiler. And this is quite unusual to have typescript and babel together in 2024, since babel can transpile the typescript code since long ago, and typescript could be used separately only to check types (not for transpiling)

from js-lingui.

simlmx avatar simlmx commented on June 9, 2024

Here is where I was coming from, in case it makes the use-case clearer.

My starting point was a pure Typescript project (no Babel or SWC whatsoever). What I'm doing is closer to a react component library than to a website, and I'm happy without any transpilation. I then simply followed the React project instructions to install lingui.

Thanks again for the help!

from js-lingui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.