TS parser not working anymore (TS5095: Unable to compile TypeScript)

See original GitHub issue

Describe the bug I18N-Ally cant parse my translation files anymore. I use Svelte and Typescript Translation Files. See Error below.

It used to work before, now it doesnt Β―_(ツ)_/Β―.

Extension Version v2.8.1

Framework/i18n package you are using Svelte, Typescript-Parser

Device Infomation

  • OS: Windows 11
  • Version: 22000.376
  • VS Code Version: 1.63.2

Extension Log Go to View -> Output -> i18n Ally, and paste the content below. You should mask any sensitive information

🈢 Activated, v2.8.1

――――――

πŸ’Ό Workspace root changed to "c:\project"
🌞 Enabled
🧩 Enabled frameworks: Svelte
🧬 Enabled parsers: ts

πŸ“ˆ Telemetry id: 2a7c1185-c100-48f4-8684-b148e8ffe963
πŸš€ Initializing loader "c:\project"
πŸ“‚ Directory structure: file
πŸ—ƒ Path Matcher Regex: /^(?<locale>[\w-_]+)\.(?<ext>ts)$/

πŸ“‚ Loading locales under c:\project\src\i18n
	πŸ“‘ Loading (de) de.ts [1639728684800.5498]
		πŸ› Failed to load Error: Command failed: node "c:\Users\Someone\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\dist\bin.js" --dir "c:\project" --transpile-only --compiler-options "{\"importHelpers\":false,\"allowJs\":true,\"module\":\"commonjs\"}" "c:\Users\Someone\.vscode\extensions\lokalise.i18n-ally-2.8.1\assets\loader.js" "c:\project\src\i18n\de.ts"

c:\Users\Someone\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\src\index.ts:513
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: β¨― Unable to compile TypeScript:
error TS5095: Option 'preserveValueImports' can only be used when 'module' is set to 'es2015' or later.

    at createTSError (c:\Users\Someone\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\src\index.ts:513:12)
    at reportTSError (c:\Users\Someone\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\src\index.ts:517:19)
    at getOutput (c:\Users\Someone\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\src\index.ts:955:34)
    at Object.compile (c:\Users\Someone\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\src\index.ts:968:32)
    at Module.m._compile (c:\Users\Someone\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\src\index.ts:1056:42)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .js] (c:\Users\Someone\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\src\index.ts:1059:12)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Alfagun74commented, Dec 20, 2021

@terales im running on the latest version 1.63.2

0reactions
Coretteketcommented, Aug 27, 2022

I had the same issue, but solving it for me was a little more involved: Running yarn add -D ts-node failed, because yarn couldn’t find fluent-vue-cli. Luckily, removing that dependency didn’t seem to break things. Then, I got a new error in my output:

πŸ› Failed to load Error: Command failed: node "c:\Users\Qcoret\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\dist\bin.js" --dir "c:\Users\Qcoret\Documents\qntn.io" --transpile-only --compiler-options "{\"importHelpers\":false,\"allowJs\":true,\"module\":\"commonjs\"}" "c:\Users\Qcoret\.vscode\extensions\lokalise.i18n-ally-2.8.1\assets\loader.js" "c:\Users\Qcoret\Documents\qntn.io\src\i18n\loader.ts"
c:\Users\Qcoret\.vscode\extensions\lokalise.i18n-ally-2.8.1\node_modules\ts-node\dist-raw\node-internal-errors.js:46
const err = new Error(getErrRequireEsmMessage(filename, parentPath, packageJsonPath))
              ^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: c:\Users\Qcoret\Documents\qntn.io\src\scripts\flatten.ts
require() of ES modules is not supported.
require() of c:\Users\Qcoret\Documents\qntn.io\src\scripts\flatten.ts from c:\Users\Qcoret\Documents\qntn.io\src\i18n\loader.ts is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from c:\Users\Qcoret\Documents\qntn.io\package.json.

I ended up creating a phantom package.json in my src/i18n folder, without a "type": "module" (and immediately added the file to my .gitignore and vscode ignore). That seems to have resolved the issue, but this certainly seems like something that should/could be fixed on the package level.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: TSError: Unable to compile TypeScript - Stack Overflow
First I remove ts-node and typescript from package.json . then, ... If only the npm install -g typescript doesn't work.
Read more >
Compile and build TypeScript code using NuGet
Learn how to add TypeScript support to your Visual Studio projects by using the NuGet package.
Read more >
How to Set Up a Node.js Project with TypeScript
Compiling TypeScript Files for Node.js. Go ahead and create the aforementioned src directory in your project root, and place a main.ts fileΒ ...
Read more >
Babel vs. TypeScript: Choosing the right compiler for your ...
Previously, this meant that Babel did not support TypeScript features that ... you should be able to compile all valid TypeScript codebases.
Read more >
TypeScript - webpack
In this guide we will learn how to integrate TypeScript with webpack. Basic Setup. First install the TypeScript compiler and loader by running:...
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