Skip to content

Extension fails to load TypeScript files in Expo projects due to tsconfig incompatibility #1350

@june20516

Description

@june20516

Describe the bug

i18n-ally extension cannot load TypeScript locale files in Expo React Native projects. The extension's internal TypeScript loader configuration conflicts with Expo's default tsconfig settings.

Extension Version

  • i18n-ally version: 2.13.1
  • Project: Expo React Native ~53.0.16
  • TypeScript: 5.8.3

Framework/i18n package you are using

  • Framework: React Native (Expo)
  • i18n package: i18n-js ^4.5.1
  • Custom framework configuration
languageIds:
  - javascript
  - typescript
  - javascriptreact
  - typescriptreact
  - ejs

usageMatchRegex:
  - "\\bt\\(['\"`]({key})['\"`]"
  - "(?:i18n|I18n)\\.t\\(\\s*['\"`]({key})['\"`]"

derivedKeyRules:
  - "const flat = \\{[\\s\\S]*?['\"`]({key})['\"`]\\s*:"
  - "['\"`]({key})['\"`]\\s*:"

refactorTemplates:
  - source: '{key}'
    target: "t('{key}')"

monopoly: true

To Reproduce
Steps to reproduce the behavior:

  1. Create an Expo React Native project (which uses
    moduleResolution: "bundler" by default)
  2. Set up i18n-ally with TypeScript locale files:
  // .vscode/settings.json
  {
    "i18n-ally.localesPaths": ["src/constants/locales"],
    "i18n-ally.pathMatcher": "{locale}.ts",
    "i18n-ally.enabledParsers": ["ts"]
  }
  1. Create locale files: src/constants/locales/en.ts,
    src/constants/locales/ko.ts
  2. Open the project in VS Code
  3. Check the i18n Ally output - see the TypeScript compilation error

Device Infomation

  • OS:
  • Version:
  • VS Code Version:
    • Windsurf Version: 1.12.12
    • Windsurf Extension Version: 1.48.2
    • VSCode OSS Version: 1.99.3

Extension Log

🈶 Activated, v2.13.1

――――――

💼 Workspace root changed to "/Users/bran/repositories/front-taap-stpm"
🍱 Custom framework setting loaded. 
{
  "languageIds": [
    "javascript",
    "typescript",
    "javascriptreact",
    "typescriptreact",
    "ejs"
  ],
  "usageMatchRegex": [
    "\\bt\\(['\"`]({key})['\"`]",
    "(?:i18n|I18n)\\.t\\(\\s*['\"`]({key})['\"`]"
  ],
  "derivedKeyRules": [
    "const flat = \\{[\\s\\S]*?['\"`]({key})['\"`]\\s*:",
    "['\"`]({key})['\"`]\\s*:"
  ],
  "refactorTemplates": [
    {
      "source": "{key}",
      "target": "t('{key}')"
    }
  ],
  "monopoly": true
}

🌞 Enabled
🧩 Enabled frameworks: Custom
🧬 Enabled parsers: ts

📈 Telemetry id: d4ff8e1e-1d6f-42b1-a230-073ba4978fec
🚀 Initializing loader "/Users/bran/repositories/front-taap-stpm"
📂 Directory structure: file
🗃 Custom Path Matcher: {locale}.ts
🗃 Path Matcher Regex: /^(?<locale>[\w-_]+)\.ts$/

📂 Loading locales under /Users/bran/repositories/front-taap-stpm/src/constants/locales
	📑 Loading (en) en.ts [1759193295714.4775]
		🐛 Failed to load Error: Command failed: node "/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/dist/bin.js" --dir "/Users/bran/repositories/front-taap-stpm" --transpile-only --compiler-options "{\"importHelpers\":false,\"allowJs\":true,\"module\":\"commonjs\"}" "/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/assets/loader.js" "/Users/bran/repositories/front-taap-stpm/src/constants/locales/en.ts"

/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:513
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.

    at createTSError (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:513:12)
    at reportTSError (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:517:19)
    at getOutput (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:955:34)
    at Object.compile (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:968:32)
    at Module.m._compile (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:1056:42)
    at node:internal/modules/cjs/loader:1820:10
    at Object.require.extensions.<computed> [as .js] (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (node:internal/modules/cjs/loader:1423:32)
    at Function._load (node:internal/modules/cjs/loader:1246:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)

	📑 Loading (ko) ko.ts [1759193295714.8848]
		🐛 Failed to load Error: Command failed: node "/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/dist/bin.js" --dir "/Users/bran/repositories/front-taap-stpm" --transpile-only --compiler-options "{\"importHelpers\":false,\"allowJs\":true,\"module\":\"commonjs\"}" "/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/assets/loader.js" "/Users/bran/repositories/front-taap-stpm/src/constants/locales/ko.ts"

/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:513
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later.

    at createTSError (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:513:12)
    at reportTSError (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:517:19)
    at getOutput (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:955:34)
    at Object.compile (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:968:32)
    at Module.m._compile (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:1056:42)
    at node:internal/modules/cjs/loader:1820:10
    at Object.require.extensions.<computed> [as .js] (/Users/bran/.windsurf/extensions/lokalise.i18n-ally-2.13.1-universal/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (node:internal/modules/cjs/loader:1423:32)
    at Function._load (node:internal/modules/cjs/loader:1246:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)


👀 Watching change on /Users/bran/repositories/front-taap-stpm/src/constants/locales
✅ Loading finished


――――――


Additional Context

I believe IDE extensions would ideally work flexibly across different project configurations. However, the extension currently hard-codes TypeScript compiler options (module: "commonjs") that conflict with Expo's default configuration, making it unable to work in Expo projects.

This affects the ability to use TypeScript locale files in Expo projects, which is a common setup in the React Native ecosystem.
Would it be possible to make the extension's TypeScript loader more flexible to support different project configurations?

Thank you for maintaining this useful extension!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions