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

Typescript extractor #228

Merged
merged 7 commits into from
Jun 24, 2018
Merged

Conversation

huan086
Copy link
Contributor

@huan086 huan086 commented Jun 16, 2018

Resolves #151 by using typescript to output ES2016 to preserve tagged template literal, and to preserve JSX. The result is then passed to existing lingui transforms and extract.

Known issues: typescript currently supports new features like fragment syntax <>children</>, but these are only supported in Babel 7. Thus the extractor cannot parse files using the new features. I'm not sure if we should upgrade to Babel 7 (still in beta) to solve this.

@huan086
Copy link
Contributor Author

huan086 commented Jun 16, 2018

One more thing, no idea where to write unit test for this

@tricoder42
Copy link
Contributor

@huan086 Thank you for this PR! Great work!

Babel 7 will be used in next major version (3.x). Right now it's used in master branch, but I haven't merge stabel-2.x for a while. I'll take a look. Would be great to keep these two branches as close as possible so we can release 3.x once Babel 7 becomes officially available.

For the unittests, I would put then in src/api/extractors/typescript.test.js, but atm I have no idea how to write them.

@huan086
Copy link
Contributor Author

huan086 commented Jun 17, 2018

Currently writing the Typescript definitions and submitting them to DefinitelyTyped. Facing difficulties for @lingui/react because the react types are quite hard to understand.

After the typings are done, I'll be able to write the unit tests without typescript complaining about xxx is not a module.

Fix typescript extractor not able to parse non-JSX Typescript files.
@tricoder42
Copy link
Contributor

This looks solid! Would you be interested in updating Typescript guide? Is there any special setup required to make typescript work or is it enough to install @lingul/cli and run lingui extract?

@huan086
Copy link
Contributor Author

huan086 commented Jun 20, 2018

No special setup needed. The original typescript implementation already did all the groundwork 😊

@tricoder42
Copy link
Contributor

Awesome! 👍

@tricoder42 tricoder42 merged commit 17749e4 into lingui:stable-2.x Jun 24, 2018
@tricoder42
Copy link
Contributor

Fixed and released in v2.2.0. Thanks to all involved!

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

Successfully merging this pull request may close these issues.

2 participants