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.

Typescript support

See original GitHub issue

Finalize 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 and i18n.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

  1. 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 in scripts/jest/config.unit.js to run the test suit.
  2. Check that plugin works on Test project (provided by @papoola)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
quentezcommented, Feb 26, 2018

@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.

3reactions
rssfrncscommented, May 23, 2018

FYI - I’m using Typescript as a Babel (v7) preset and extraction is working fine with .tsx files.

Read more comments on GitHub >

github_iconTop 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 >

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