question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unknown Expression of type "TemplateLiteral"

See original GitHub issue

Describe the bug

CLI related: When running lingui extract I’m getting the following error:

~/code/react-testing-library-course (wip/lingui)
😎  $ lingui extract
/Users/kdodds/code/react-testing-library-course/node_modules/regenerator-transform/lib/emit.js:946
      throw new Error("unknown Expression of type " + JSON.stringify(expr.type));
      ^

Error: unknown Expression of type "TemplateLiteral"
    at Emitter.Ep.explodeExpression (/Users/kdodds/code/react-testing-library-course/node_modules/regenerator-transform/lib/emit.js:946:13)
    at explodeViaTempVar (/Users/kdodds/code/react-testing-library-course/node_modules/regenerator-transform/lib/emit.js:742:23)
    at /Users/kdodds/code/react-testing-library-course/node_modules/regenerator-transform/lib/emit.js:827:54
    at Array.map (<anonymous>)
    at Emitter.Ep.explodeExpression (/Users/kdodds/code/react-testing-library-course/node_modules/regenerator-transform/lib/emit.js:825:63)
    at explodeViaTempVar (/Users/kdodds/code/react-testing-library-course/node_modules/regenerator-transform/lib/emit.js:742:23)
    at /Users/kdodds/code/react-testing-library-course/node_modules/regenerator-transform/lib/emit.js:827:54
    at Array.map (<anonymous>)
    at Emitter.Ep.explodeExpression (/Users/kdodds/code/react-testing-library-course/node_modules/regenerator-transform/lib/emit.js:825:63)
    at Emitter.Ep.explodeStatement (/Users/kdodds/code/react-testing-library-course/node_modules/regenerator-transform/lib/emit.js:524:21)

To Reproduce

I’m honestly not certain. I can’t seem to do anything to get this to not happen.

Here’s the repo/branch: https://github.com/kentcdodds/react-testing-library-course/tree/wip/lingui

Expected behavior

I expect the messages to be extracted with a proper message as indicated in the getting started guide.

Additional context

I’m trying to create a course for react-testing-library and want to include how to test with localized content loaded.

  • jsLingui version lingui --version: 2.6.0
  • Babel version npm list babel-core
~/code/react-testing-library-course (wip/lingui)
😎  $ npm list babel-core
react-testing-library-course@1.0.0 /Users/kdodds/code/react-testing-library-course
├── babel-core@7.0.0-bridge.0 
├─┬ jest@23.5.0
│ └─┬ jest-cli@23.5.0
│   ├─┬ jest-config@23.5.0
│   │ └─┬ babel-core@6.26.3 
│   │   └─┬ babel-register@6.26.0
│   │     └── babel-core@6.26.3 
│   └─┬ jest-runtime@23.5.0
│     └── babel-core@6.26.3 
└─┬ kcd-scripts@0.43.0
  └── babel-core@7.0.0-bridge.0  deduped
  • Your Babel config (e.g. .babelrc) or framework you use (Create React App, Meteor, etc.)

That’s actually a little tricky. I’m using configuration built-into kcd-scripts which you can see here is a little dynamic: https://github.com/kentcdodds/kcd-scripts/blob/master/src/config/babelrc.js

I use that as a preset and add @lingui/babel-preset-react. I suppose this could be unrelated to js-lingui, but the build and tests work fine.

Interestingly, I noticed that lingui tries to process files in my coverage directory and there doesn’t appear to be a way to tell lingui which files it should be processing… I deleted the coverage directory and tried again and had the same result so I’m confident that’s not it, but it would probably be good to not attempt to process that all the same.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kentcdoddscommented, Sep 4, 2018

Update. Using node@8 for babel-preset-env works great 👍 Thanks!

1reaction
kentcdoddscommented, Sep 2, 2018

I’ll probably just bump the minimal node version to 8 or something. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Template literal key has an 'any' type because expression of ...
You could use so known Template Literal Types. As long as the teamnames and count are known. A possible solution could look like...
Read more >
Found template literal expression having a non-string type
Found template literal expression having a non-string type JS-0378. Anti-pattern ... Invalid type "unknown" of template literal expression.
Read more >
babel/types
npm install --save-dev @babel/types ... Aliases: Standardized , Expression , Pureish , Literal , Immutable ... AST Node TemplateLiteral shape:.
Read more >
Documentation - Template Literal Types - TypeScript
When used with concrete literal types, a template literal produces a new string literal type by concatenating the contents. ts. type World =...
Read more >
The unknown Type in TypeScript - Marius Schulz
TypeScript 3.0 introduced a new unknown type which is the type-safe counterpart of the any type.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found