Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable TypeScript based config #940

Closed
danielkcz opened this issue Jan 13, 2021 · 1 comment · Fixed by #941
Closed

Enable TypeScript based config #940

danielkcz opened this issue Jan 13, 2021 · 1 comment · Fixed by #941

Comments

@danielkcz
Copy link
Contributor

danielkcz commented Jan 13, 2021

Is your feature request related to a problem? Please describe.
I want to extract configured locales and default locales to a separate file (i18n.config.ts) so it can be consumed by other parts of the app without duplicating configuration with full type support. But such a file cannot be imported inside the lingui.config.js file.

Furthermore, Typescript based config allows using ESM easily to have everything nicely typed.

Describe proposed solution
The cosmiconfig allows using custom loaders and to specify custom search paths. Specifically, there is official Typescript loader where you can see how the configuration looks like. It's pretty straightforward.

https://github.com/EndemolShineGroup/cosmiconfig-typescript-loader

Describe alternatives you've considered
An alternative is to keep using untyped lingui.config.js and suffer from it :)

Additional context
There is a slight issue in the linked loader plugin which makes it work only with async code. Since the Lingui is using cosmiconfigSync() it doesn't work together. I already created the PR to address that, but the loader seems unmaintained.

However, if you look at its source code, it's like 15 LoC so I wouldn't hesitate much to just copy & paste it inside Lingui. Given it's for the CLI, it doesn't matter that much.

I am willing to make a PR if you would accept this approach.

@danielkcz danielkcz changed the title Enabled TypeScript based config Enable TypeScript based config Jan 13, 2021
@semoal
Copy link
Contributor

semoal commented Jan 13, 2021

Its a nice idea for me everything that improves development experience is welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants