From 81cd8b3c72a4bf349423e9ea38fc08c7e9496cbb Mon Sep 17 00:00:00 2001 From: Timofei Iatsenko Date: Mon, 8 Jul 2024 09:54:05 +0200 Subject: [PATCH] fix(experimental-extractor): change default loader to tsx Because we use babel to process only macro in esbuild plugin and left rest of the syntax (including typescript) as-is we have to specify correct loader for esbuild. I choosed tsx loader because it's a superset and do everything what js and ts and tsx loaders could do without relying on file extension --- .../cli/src/extract-experimental/linguiEsbuildPlugin.ts | 2 +- .../extractor-experimental/fixtures/pages/index.page.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/extract-experimental/linguiEsbuildPlugin.ts b/packages/cli/src/extract-experimental/linguiEsbuildPlugin.ts index b678201d8..1064a7c17 100644 --- a/packages/cli/src/extract-experimental/linguiEsbuildPlugin.ts +++ b/packages/cli/src/extract-experimental/linguiEsbuildPlugin.ts @@ -50,7 +50,7 @@ export const pluginLinguiMacro = (options: { ], }) - return { contents: result.code, loader: "jsx" } + return { contents: result.code, loader: "tsx" } }) }, }) diff --git a/packages/cli/test/extractor-experimental/fixtures/pages/index.page.ts b/packages/cli/test/extractor-experimental/fixtures/pages/index.page.ts index 7a39f67bf..8ddf8db66 100644 --- a/packages/cli/test/extractor-experimental/fixtures/pages/index.page.ts +++ b/packages/cli/test/extractor-experimental/fixtures/pages/index.page.ts @@ -1,6 +1,10 @@ import { t } from "@lingui/core/macro" import { RED } from "../constants" -const msg = t`index page message` +const msg: string = t`index page message` console.log(msg) console.log(RED) + +function test(input: string): void { + console.log("Should support TS type annotation syntax") +}