Is your feature request related to a problem? Please describe.
I am always frustrated when I have to allow ts to import js messages (eslint) or when I have to reconfigure the ts config to serve .mjs files.
Having imported
import { messages } from './locales/en/messages.mjs';
I need to:
*.mjs case allow typescript to serve multiple extensions*.js case disable import extensions checkDescribe proposed solution
I would like to configure the extension like this:
.linguirc
{
...
"compileNamespace": "es",
"compileExtension": "ts",
}
Describe alternatives you've considered
There is always alternative to setup eslint but it does not sound like a big deal to have it in config.
I have also tried to rename the file to *.ts extension and it works like charm, (thank you @laszbalo). Example below.
"lingui:compile": "lingui compile && for f in $(find ./src/locales/* -type f -name '*.mjs'); do mv \"$f\" \"${f%.mjs}.ts\"; done"
Additional context
I am using standard Create-React-App bundler with default settings, with airbnb and recommended eslint plugins.
https://github.com/lingui/js-lingui/blob/main/packages/cli/src/api/catalog.ts#L347
improving a bit this method, this feature could be done, if someone wants to collaborate
I should find some time next week to prepare a pull request.
Currently I've found lingui compile --typescript and it does the job (but there is no eslint exclusion on messages.d.ts file). I will also try to add it.
Note that lingui compile --typescript merely adds a .d.ts file with a type definition for the .js file. It is also undocumented (but so is a lot of lingui 3, it appears).
Released in 3.4.0 馃コ, also with the new version we accept lingui.config.ts thanks to @FredyC
Wow! Thanks @semoal, thanks @FredyC. Lingui is awesome, I'll be happy to contribute on later stages!