Typescript support
See original GitHub issueFinalize plugin for extracting messages from typescript files. This need somebody with Typescript experience.
Status
Base of plugin is created in typescript-extract-messages package (original version created by @johansigfrids). It uses the same test suite as babel-plugin-extract-messages
. Extracting of messages works, but there’re few problems:
- babel plugin also transforms file and removes
i18nMark
functions, because they are used only to mark strings for extraction. Typescript plugin so far doesn’t modify original file and I don’t know if Typescript works in the same way as Babel. - babel transform plugins take
<Trans>
tags andi18n.t
calls and transform them into low-level API calls. Since there’re no transform plugins for typescript which would do the same, typescript users have to use low-level API directly. - plugin doesn’t check imports - Trans component and i18n object might be aliased
Once the plugin is finish, it can be easily hooked to CLI:
import extract from "@lingui/typescript-extract-messages"
const extractor: ExtractorType = {
...
extract(filename, targetDir) {
extract(filename, { localeDir: targetDir })
}
}
Goals
- All tests must pass (should be the same test suit as for
babel-extract-messages
plugin or at least very similar). Remove typescript plugin from ignored modules inscripts/jest/config.unit.js
to run the test suit. - Check that plugin works on Test project (provided by @papoola)
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:12 (6 by maintainers)
Top Results From Across the Web
TypeScript: JavaScript With Syntax For Types.
TypeScript extends JavaScript by adding types to the language. TypeScript speeds up your development experience by catching errors and providing fixes ...
Read more >TypeScript - Wikipedia
TypeScript supports definition files that can contain type information of existing JavaScript libraries, much like C++ header files can describe the ...
Read more >TypeScript Programming with Visual Studio Code
Visual Studio Code includes TypeScript language support but does not include the TypeScript compiler, tsc . You will need to install the TypeScript...
Read more >TypeScript | IntelliJ IDEA Documentation - JetBrains
IntelliJ IDEA supports developing, running, and debugging TypeScript source code. IntelliJ IDEA recognizes .ts and .tsx files and provides ...
Read more >TypeScript Introduction - W3Schools
TypeScript is JavaScript with added syntax for types. ... as Visual Studio Code, have built-in TypeScript support and can show errors as you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tricoder42 Babel has beta support for TypeScript in version 7. Would it be easier to write the extractor by relying on that instead?
UPDATE: I was able to get something working. I’ll publish an update.
FYI - I’m using Typescript as a Babel (v7) preset and extraction is working fine with
.tsx
files.