Hello World!
@@ -308,7 +308,7 @@ const cases: TestCase[] = [
name: "Elements inside expression container",
stripId: true,
input: `
- import { Trans } from '@lingui/macro';
+ import { Trans } from '@lingui/react/macro';
{Component inside expression container};
`,
expected: `
@@ -326,7 +326,7 @@ const cases: TestCase[] = [
name: "Elements without children",
stripId: true,
input: `
- import { Trans } from '@lingui/macro';
+ import { Trans } from '@lingui/react/macro';
{
};
`,
expected: `
@@ -340,7 +340,7 @@ const cases: TestCase[] = [
name: "Production - only essential props are kept",
production: true,
input: `
- import { Trans } from '@lingui/macro';
+ import { Trans } from '@lingui/react/macro';
Hello World
`,
expected: `
@@ -355,7 +355,7 @@ const cases: TestCase[] = [
extract: true,
},
input: `
- import { Trans } from '@lingui/macro';
+ import { Trans } from '@lingui/react/macro';
Hello World
`,
expected: `
@@ -369,7 +369,7 @@ const cases: TestCase[] = [
useTypescriptPreset: true,
input: `
import type { withI18nProps } from '@lingui/react'
- import { Trans } from '@lingui/macro';
+ import { Trans } from '@lingui/react/macro';
Hello World
`,
expected: `
@@ -381,7 +381,7 @@ const cases: TestCase[] = [
name: "Strip whitespace around arguments",
stripId: true,
input: `
- import { Trans } from "@lingui/macro";
+ import { Trans } from "@lingui/react/macro";
Strip whitespace around arguments: '
{name}
@@ -399,7 +399,7 @@ const cases: TestCase[] = [
name: "Strip whitespace around tags but keep forced spaces",
stripId: true,
input: `
- import { Trans } from "@lingui/macro";
+ import { Trans } from "@lingui/react/macro";
Strip whitespace around tags, but keep{" "}
forced spaces
@@ -417,7 +417,7 @@ const cases: TestCase[] = [
name: "Keep forced newlines",
stripId: true,
input: `
- import { Trans } from "@lingui/macro";
+ import { Trans } from "@lingui/react/macro";
Keep forced{"\\n"}
newlines!
@@ -432,7 +432,7 @@ const cases: TestCase[] = [
name: "Keep multiple forced newlines",
stripId: true,
input: `
- import { Trans } from "@lingui/macro";
+ import { Trans } from "@lingui/react/macro";
Keep multiple{"\\n"}
forced{"\\n"}
@@ -448,7 +448,8 @@ const cases: TestCase[] = [
name: "Use a js macro inside a JSX Attribute of a component handled by JSX macro",
stripId: true,
input: `
- import { t, Trans } from '@lingui/macro';
+ import { Trans } from '@lingui/react/macro';
+ import { t } from '@lingui/core/macro';
Read more
`,
expected: `
@@ -481,7 +482,7 @@ const cases: TestCase[] = [
{
name: "Use a js macro inside a JSX Attribute of a non macro JSX component",
input: `
- import { plural } from '@lingui/macro';
+ import { plural } from '@lingui/core/macro';
Hello {/* and I cannot stress this enough */} World;
`,
expected: `
@@ -522,7 +523,7 @@ const cases: TestCase[] = [
name: "Use decoded html entities",
stripId: true,
input: `
- import { Trans } from "@lingui/macro";
+ import { Trans } from "@lingui/react/macro";
&
`,
expected: `
@@ -535,7 +536,7 @@ const cases: TestCase[] = [
useTypescriptPreset: true,
stripId: true,
input: `
- import { Trans } from "@lingui/macro";
+ import { Trans } from "@lingui/react/macro";
type X = typeof Trans;
const cmp = Hello
`,
diff --git a/packages/macro/test/lingui.config.js b/packages/babel-plugin-lingui-macro/test/lingui.config.js
similarity index 100%
rename from packages/macro/test/lingui.config.js
rename to packages/babel-plugin-lingui-macro/test/lingui.config.js
diff --git a/packages/babel-plugin-lingui-macro/tsconfig.json b/packages/babel-plugin-lingui-macro/tsconfig.json
new file mode 100644
index 000000000..8965e0cbd
--- /dev/null
+++ b/packages/babel-plugin-lingui-macro/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "strict": true,
+ "strictNullChecks": false,
+ }
+}
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 985021f82..ba6041259 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -54,12 +54,11 @@
"@babel/runtime": "^7.21.0",
"@babel/types": "^7.21.2",
"@lingui/babel-plugin-extract-messages": "4.8.0-next.1",
+ "@lingui/babel-plugin-lingui-macro": "4.8.0-next.1",
"@lingui/conf": "4.8.0-next.1",
"@lingui/core": "4.8.0-next.1",
"@lingui/format-po": "4.8.0-next.1",
- "@lingui/macro": "4.8.0-next.1",
"@lingui/message-utils": "4.8.0-next.1",
- "babel-plugin-macros": "^3.0.1",
"chalk": "^4.1.0",
"chokidar": "3.5.1",
"cli-table": "0.3.6",
diff --git a/packages/cli/src/api/__snapshots__/catalog.test.ts.snap b/packages/cli/src/api/__snapshots__/catalog.test.ts.snap
index 39cd5237d..2d9d533e3 100644
--- a/packages/cli/src/api/__snapshots__/catalog.test.ts.snap
+++ b/packages/cli/src/api/__snapshots__/catalog.test.ts.snap
@@ -129,7 +129,7 @@ exports[`Catalog collect should support JSX and Typescript 1`] = `
origin: [
[
collect-typescript-jsx/macro.tsx,
- 11,
+ 12,
],
],
},
@@ -140,7 +140,7 @@ exports[`Catalog collect should support JSX and Typescript 1`] = `
origin: [
[
collect-typescript-jsx/macro.tsx,
- 19,
+ 20,
],
],
},
@@ -153,7 +153,7 @@ exports[`Catalog collect should support JSX and Typescript 1`] = `
origin: [
[
collect-typescript-jsx/macro.tsx,
- 6,
+ 7,
],
],
},
@@ -164,7 +164,7 @@ exports[`Catalog collect should support JSX and Typescript 1`] = `
origin: [
[
collect-typescript-jsx/macro.tsx,
- 18,
+ 19,
],
],
},
@@ -175,7 +175,7 @@ exports[`Catalog collect should support JSX and Typescript 1`] = `
origin: [
[
collect-typescript-jsx/macro.tsx,
- 17,
+ 18,
],
],
},
@@ -186,7 +186,7 @@ exports[`Catalog collect should support JSX and Typescript 1`] = `
origin: [
[
collect-typescript-jsx/macro.tsx,
- 21,
+ 22,
],
],
},
@@ -197,7 +197,7 @@ exports[`Catalog collect should support JSX and Typescript 1`] = `
origin: [
[
collect-typescript-jsx/macro.tsx,
- 4,
+ 5,
],
],
},
diff --git a/packages/cli/src/api/extractors/babel.ts b/packages/cli/src/api/extractors/babel.ts
index a2fe6c673..2dd2ed7c9 100644
--- a/packages/cli/src/api/extractors/babel.ts
+++ b/packages/cli/src/api/extractors/babel.ts
@@ -9,8 +9,8 @@ import linguiExtractMessages from "@lingui/babel-plugin-extract-messages"
import type { ExtractorType } from "@lingui/conf"
import { ParserPlugin } from "@babel/parser"
-import { type LinguiPluginOpts } from "@lingui/macro/plugin"
-import linguiMacroPlugin from "@lingui/macro/plugin"
+import { type LinguiPluginOpts } from "@lingui/babel-plugin-lingui-macro"
+import linguiMacroPlugin from "@lingui/babel-plugin-lingui-macro"
import { ExtractedMessage, ExtractorCtx } from "@lingui/conf"
const babelRe = new RegExp(
diff --git a/packages/cli/src/api/fixtures/collect-inline-sourcemaps/componentB.jsx b/packages/cli/src/api/fixtures/collect-inline-sourcemaps/componentB.jsx
index ead6e4e5c..13bcc2584 100644
--- a/packages/cli/src/api/fixtures/collect-inline-sourcemaps/componentB.jsx
+++ b/packages/cli/src/api/fixtures/collect-inline-sourcemaps/componentB.jsx
@@ -1,3 +1,3 @@
-import { Trans } from "@lingui/macro"
+import { Trans } from "@lingui/react/macro"
;Some message
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5wdXQuanN4Iiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiaW5wdXQudHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLEVBQUUsTUFBTSxlQUFlLENBQUE7QUFJckMsQ0FBQyxLQUFLLENBQUMsT0FBTyxDQUFDLFVBQVUsQ0FBQyxZQUFZLEVBQUUsS0FBSyxDQUFDLENBQUEifQ==
diff --git a/packages/cli/src/api/fixtures/collect-typescript-jsx/macro.tsx b/packages/cli/src/api/fixtures/collect-typescript-jsx/macro.tsx
index 3f499dcd9..1f9580a70 100644
--- a/packages/cli/src/api/fixtures/collect-typescript-jsx/macro.tsx
+++ b/packages/cli/src/api/fixtures/collect-typescript-jsx/macro.tsx
@@ -1,17 +1,18 @@
-import { t, defineMessage, plural, Trans } from "@lingui/macro"
+import { t, defineMessage, plural } from "@lingui/core/macro"
+import { Trans } from "@lingui/react/macro"
// JS Macro usages
const msg = t`Message`
const withDescription = defineMessage({
- message: 'Description',
- comment: "description"
+ message: "Description",
+ comment: "description",
})
const withTId = t({
- id: "ID Some",
- message: "Message with id some"
- })
+ id: "ID Some",
+ message: "Message with id some",
+})
// JSX Macro usages
;Hi, my name is {name}
@@ -20,6 +21,6 @@ const withTId = t({
;
diff --git a/packages/cli/src/api/fixtures/collect-typescript-jsx/tsx-experimental-decorators.tsx b/packages/cli/src/api/fixtures/collect-typescript-jsx/tsx-experimental-decorators.tsx
index 7e2ca4de5..a34ea030f 100644
--- a/packages/cli/src/api/fixtures/collect-typescript-jsx/tsx-experimental-decorators.tsx
+++ b/packages/cli/src/api/fixtures/collect-typescript-jsx/tsx-experimental-decorators.tsx
@@ -1,4 +1,4 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
@Decorator()
export class TestDecorator {
diff --git a/packages/cli/test/extract-po-format/fixtures/file-a.ts b/packages/cli/test/extract-po-format/fixtures/file-a.ts
index 995dc7284..6e305a82a 100644
--- a/packages/cli/test/extract-po-format/fixtures/file-a.ts
+++ b/packages/cli/test/extract-po-format/fixtures/file-a.ts
@@ -1,4 +1,4 @@
-import { defineMessage, t } from "@lingui/macro"
+import { defineMessage, t } from "@lingui/core/macro"
import { i18n } from "@lingui/core"
const msg = t`Hello world`
diff --git a/packages/cli/test/extract-po-format/fixtures/file-b.tsx b/packages/cli/test/extract-po-format/fixtures/file-b.tsx
index 5c771448f..3bb619e3d 100644
--- a/packages/cli/test/extract-po-format/fixtures/file-b.tsx
+++ b/packages/cli/test/extract-po-format/fixtures/file-b.tsx
@@ -1,4 +1,4 @@
-import { Trans } from "@lingui/macro"
+import { Trans } from "@lingui/react/macro"
import React from "react"
export function MyComponent() {
diff --git a/packages/cli/test/extract-template-po-format/fixtures/file-a.ts b/packages/cli/test/extract-template-po-format/fixtures/file-a.ts
index 995dc7284..6e305a82a 100644
--- a/packages/cli/test/extract-template-po-format/fixtures/file-a.ts
+++ b/packages/cli/test/extract-template-po-format/fixtures/file-a.ts
@@ -1,4 +1,4 @@
-import { defineMessage, t } from "@lingui/macro"
+import { defineMessage, t } from "@lingui/core/macro"
import { i18n } from "@lingui/core"
const msg = t`Hello world`
diff --git a/packages/cli/test/extract-template-po-format/fixtures/file-b.tsx b/packages/cli/test/extract-template-po-format/fixtures/file-b.tsx
index 5c771448f..3bb619e3d 100644
--- a/packages/cli/test/extract-template-po-format/fixtures/file-b.tsx
+++ b/packages/cli/test/extract-template-po-format/fixtures/file-b.tsx
@@ -1,4 +1,4 @@
-import { Trans } from "@lingui/macro"
+import { Trans } from "@lingui/react/macro"
import React from "react"
export function MyComponent() {
diff --git a/packages/cli/test/extractor-experimental-clean/fixtures/components/header.ts b/packages/cli/test/extractor-experimental-clean/fixtures/components/header.ts
index 4fb7c2973..1a18d198a 100644
--- a/packages/cli/test/extractor-experimental-clean/fixtures/components/header.ts
+++ b/packages/cli/test/extractor-experimental-clean/fixtures/components/header.ts
@@ -1,3 +1,3 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
export const msg = t`header message`
diff --git a/packages/cli/test/extractor-experimental-clean/fixtures/pages/about.page.ts b/packages/cli/test/extractor-experimental-clean/fixtures/pages/about.page.ts
index 5859178db..51d7d2db0 100644
--- a/packages/cli/test/extractor-experimental-clean/fixtures/pages/about.page.ts
+++ b/packages/cli/test/extractor-experimental-clean/fixtures/pages/about.page.ts
@@ -1,4 +1,4 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
import { msg as headerMsg } from "../components/header"
const msg = t`about page message`
diff --git a/packages/cli/test/extractor-experimental-clean/fixtures/pages/index.page.ts b/packages/cli/test/extractor-experimental-clean/fixtures/pages/index.page.ts
index c4b70e63e..223a82385 100644
--- a/packages/cli/test/extractor-experimental-clean/fixtures/pages/index.page.ts
+++ b/packages/cli/test/extractor-experimental-clean/fixtures/pages/index.page.ts
@@ -1,4 +1,4 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
const msg = t`index page message`
console.log(msg)
diff --git a/packages/cli/test/extractor-experimental-clean/package.json b/packages/cli/test/extractor-experimental-clean/package.json
index 460c3aa64..b4e8874a8 100644
--- a/packages/cli/test/extractor-experimental-clean/package.json
+++ b/packages/cli/test/extractor-experimental-clean/package.json
@@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"dependencies": {
- "@lingui/macro": "*"
+ "@lingui/core": "*"
}
}
diff --git a/packages/cli/test/extractor-experimental-template/expected/about.page.messages.pot b/packages/cli/test/extractor-experimental-template/expected/about.page.messages.pot
index c5fd45083..3b01c9627 100644
--- a/packages/cli/test/extractor-experimental-template/expected/about.page.messages.pot
+++ b/packages/cli/test/extractor-experimental-template/expected/about.page.messages.pot
@@ -6,7 +6,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
-#: fixtures/pages/about.page.tsx:15
+#: fixtures/pages/about.page.tsx:16
msgid "about page message"
msgstr ""
@@ -18,6 +18,6 @@ msgstr ""
msgid "header message"
msgstr ""
-#: fixtures/pages/about.page.tsx:18
+#: fixtures/pages/about.page.tsx:19
msgid "JSX: about page message"
msgstr ""
diff --git a/packages/cli/test/extractor-experimental-template/fixtures/components/aliased-module.ts b/packages/cli/test/extractor-experimental-template/fixtures/components/aliased-module.ts
index 7165a91c0..df60238e5 100644
--- a/packages/cli/test/extractor-experimental-template/fixtures/components/aliased-module.ts
+++ b/packages/cli/test/extractor-experimental-template/fixtures/components/aliased-module.ts
@@ -1,3 +1,3 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
export const msg = t`aliased module message`
diff --git a/packages/cli/test/extractor-experimental-template/fixtures/components/header.ts b/packages/cli/test/extractor-experimental-template/fixtures/components/header.ts
index 4fb7c2973..1a18d198a 100644
--- a/packages/cli/test/extractor-experimental-template/fixtures/components/header.ts
+++ b/packages/cli/test/extractor-experimental-template/fixtures/components/header.ts
@@ -1,3 +1,3 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
export const msg = t`header message`
diff --git a/packages/cli/test/extractor-experimental-template/fixtures/pages/about.page.tsx b/packages/cli/test/extractor-experimental-template/fixtures/pages/about.page.tsx
index 4f5e8dcf5..72630c149 100644
--- a/packages/cli/test/extractor-experimental-template/fixtures/pages/about.page.tsx
+++ b/packages/cli/test/extractor-experimental-template/fixtures/pages/about.page.tsx
@@ -1,4 +1,5 @@
-import { t, Trans } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
+import { Trans } from "@lingui/react/macro"
import { msg as headerMsg } from "../components/header"
// this import should be externalized
diff --git a/packages/cli/test/extractor-experimental-template/fixtures/pages/index.page.ts b/packages/cli/test/extractor-experimental-template/fixtures/pages/index.page.ts
index c4b70e63e..223a82385 100644
--- a/packages/cli/test/extractor-experimental-template/fixtures/pages/index.page.ts
+++ b/packages/cli/test/extractor-experimental-template/fixtures/pages/index.page.ts
@@ -1,4 +1,4 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
const msg = t`index page message`
console.log(msg)
diff --git a/packages/cli/test/extractor-experimental-template/package.json b/packages/cli/test/extractor-experimental-template/package.json
index a10a360e4..2d42dc40f 100644
--- a/packages/cli/test/extractor-experimental-template/package.json
+++ b/packages/cli/test/extractor-experimental-template/package.json
@@ -3,7 +3,8 @@
"version": "1.0.0",
"private": true,
"dependencies": {
- "@lingui/macro": "*",
+ "@lingui/core": "*",
+ "@lingui/react": "*",
"some-package": "*"
}
}
diff --git a/packages/cli/test/extractor-experimental/fixtures/components/header.ts b/packages/cli/test/extractor-experimental/fixtures/components/header.ts
index 4fb7c2973..1a18d198a 100644
--- a/packages/cli/test/extractor-experimental/fixtures/components/header.ts
+++ b/packages/cli/test/extractor-experimental/fixtures/components/header.ts
@@ -1,3 +1,3 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
export const msg = t`header message`
diff --git a/packages/cli/test/extractor-experimental/fixtures/pages/about.page.ts b/packages/cli/test/extractor-experimental/fixtures/pages/about.page.ts
index 5859178db..51d7d2db0 100644
--- a/packages/cli/test/extractor-experimental/fixtures/pages/about.page.ts
+++ b/packages/cli/test/extractor-experimental/fixtures/pages/about.page.ts
@@ -1,4 +1,4 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
import { msg as headerMsg } from "../components/header"
const msg = t`about page message`
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 c4b70e63e..223a82385 100644
--- a/packages/cli/test/extractor-experimental/fixtures/pages/index.page.ts
+++ b/packages/cli/test/extractor-experimental/fixtures/pages/index.page.ts
@@ -1,4 +1,4 @@
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
const msg = t`index page message`
console.log(msg)
diff --git a/packages/cli/test/extractor-experimental/package.json b/packages/cli/test/extractor-experimental/package.json
index 4a4c8cc6d..ee4fc4d6c 100644
--- a/packages/cli/test/extractor-experimental/package.json
+++ b/packages/cli/test/extractor-experimental/package.json
@@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"dependencies": {
- "@lingui/macro": "*"
+ "@lingui/core": "*"
}
}
diff --git a/packages/macro/__typetests__/index.test-d.tsx b/packages/core/macro/__typetests__/index.test-d.tsx
similarity index 59%
rename from packages/macro/__typetests__/index.test-d.tsx
rename to packages/core/macro/__typetests__/index.test-d.tsx
index a246177e2..127d6a46c 100644
--- a/packages/macro/__typetests__/index.test-d.tsx
+++ b/packages/core/macro/__typetests__/index.test-d.tsx
@@ -8,14 +8,7 @@ import {
plural,
selectOrdinal,
select,
- Trans,
- Plural,
- Select,
- SelectOrdinal,
- useLingui,
-} from "../index"
-// eslint-disable-next-line import/no-extraneous-dependencies
-import React from "react"
+} from "@lingui/core/macro"
const name = "Jack"
const i18n: I18n = null
@@ -234,122 +227,3 @@ expectType(
other: 5,
})
)
-
-let m: any
-
-///////////////////
-//// JSX Trans
-///////////////////
-
-m = Message
-m = (
-
- Message
-
-)
-
-// @ts-expect-error: children are required here
-m =
-
-///////////////////
-//// JSX Plural
-///////////////////
-m = (
- // @ts-expect-error: children are not allowed
-
- Message
-
-)
-
-// @ts-expect-error: value is required
-m =
-
-m =
-
-// @ts-expect-error: offset could be number only
-m =
-
-// @ts-expect-error: not allowed prop is passed
-m =
-
-// should support JSX element as Props
-m = ...} other={...} />
-
-// value as string
-m =
-
-// @ts-expect-error: `other` should always be present
-m =
-
-// additional properties
-m = (
-
-)
-
-///////////////////
-//// JSX SelectOrdinal is the same s Plural, so just smoke test it
-///////////////////
-m = (
-
-)
-
-///////////////////
-//// JSX Select
-///////////////////
-m = (
- // @ts-expect-error: children are not allowed here
-
-)
-
-// @ts-expect-error: `value` could be string only
-m =
-
-// @ts-expect-error: `other` required
-m =
-
-// @ts-expect-error: `value` required
-m =
-
-m =
-
-// @ts-expect-error: exact cases should be prefixed with underscore
-m =
-
-// should support JSX in props
-m = (
- }
- other={...}
- />
-)
-
-////////////////////////
-//// React useLingui()
-////////////////////////
-function MyComponent() {
- const { t, i18n } = useLingui()
-
- expectType(t`Hello world`)
- expectType(t({ message: "my message" }))
- // @ts-expect-error: you could not pass a custom instance here
- t(i18n)({ message: "my message" })
-
- expectType(i18n)
-}
diff --git a/packages/core/macro/__typetests__/tsconfig.json b/packages/core/macro/__typetests__/tsconfig.json
new file mode 100644
index 000000000..d6980fa22
--- /dev/null
+++ b/packages/core/macro/__typetests__/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "compilerOptions": {
+ "esModuleInterop": true,
+ "skipLibCheck": true
+ },
+ "paths": {}
+}
diff --git a/packages/core/macro/index.d.ts b/packages/core/macro/index.d.ts
new file mode 100644
index 000000000..17deeca28
--- /dev/null
+++ b/packages/core/macro/index.d.ts
@@ -0,0 +1,214 @@
+import type { I18n, MessageDescriptor } from "@lingui/core"
+
+export type ChoiceOptions = {
+ /** Offset of value when calculating plural forms */
+ offset?: number
+ zero?: string
+ one?: string
+ two?: string
+ few?: string
+ many?: string
+
+ /** Catch-all option */
+ other: string
+ /** Exact match form, corresponds to =N rule */
+ [digit: `${number}`]: string
+}
+
+type MacroMessageDescriptor = (
+ | {
+ id: string
+ message?: string
+ }
+ | {
+ id?: string
+ message: string
+ }
+) & {
+ comment?: string
+ context?: string
+}
+
+/**
+ * Translates a message descriptor
+ *
+ * @example
+ * ```
+ * import { t } from "@lingui/core/macro";
+ * const message = t({
+ * id: "msg.hello",
+ * comment: "Greetings at the homepage",
+ * message: `Hello ${name}`,
+ * });
+ * ```
+ *
+ * @example
+ * ```
+ * import { t } from "@lingui/core/macro";
+ * const message = t({
+ * id: "msg.plural",
+ * message: plural(value, { one: "...", other: "..." }),
+ * });
+ * ```
+ *
+ * @param descriptor The message descriptor to translate
+ */
+export function t(descriptor: MacroMessageDescriptor): string
+
+/**
+ * Translates a template string using the global I18n instance
+ *
+ * @example
+ * ```
+ * import { t } from "@lingui/core/macro";
+ * const message = t`Hello ${name}`;
+ * ```
+ */
+export function t(
+ literals: TemplateStringsArray,
+ ...placeholders: any[]
+): string
+
+/**
+ * Translates a template string or message descriptor using a given I18n instance
+ *
+ * @example
+ * ```
+ * import { t } from "@lingui/core/macro";
+ * import { I18n } from "@lingui/core";
+ * const i18n = new I18n({
+ * locale: "nl",
+ * messages: { "Hello {0}": "Hallo {0}" },
+ * });
+ * const message = t(i18n)`Hello ${name}`;
+ * ```
+ *
+ * @example
+ * ```
+ * import { t } from "@lingui/core/macro";
+ * import { I18n } from "@lingui/core";
+ * const i18n = new I18n({
+ * locale: "nl",
+ * messages: { "Hello {0}": "Hallo {0}" },
+ * });
+ * const message = t(i18n)({ message: `Hello ${name}` });
+ * ```
+ */
+export function t(i18n: I18n): {
+ (literals: TemplateStringsArray, ...placeholders: any[]): string
+ (descriptor: MacroMessageDescriptor): string
+}
+
+/**
+ * Pluralize a message
+ *
+ * @example
+ * ```
+ * import { plural } from "@lingui/core/macro";
+ * const message = plural(count, {
+ * one: "# Book",
+ * other: "# Books",
+ * });
+ * ```
+ *
+ * @param value Determines the plural form
+ * @param options Object with available plural forms
+ */
+export function plural(value: number | string, options: ChoiceOptions): string
+
+/**
+ * Pluralize a message using ordinal forms
+ *
+ * Similar to `plural` but instead of using cardinal plural forms,
+ * it uses ordinal forms.
+ *
+ * @example
+ * ```
+ * import { selectOrdinal } from "@lingui/core/macro";
+ * const message = selectOrdinal(count, {
+ * one: "#st",
+ * two: "#nd",
+ * few: "#rd",
+ * other: "#th",
+ * });
+ * ```
+ *
+ * @param value Determines the plural form
+ * @param options Object with available plural forms
+ */
+export function selectOrdinal(
+ value: number | string,
+ options: ChoiceOptions
+): string
+
+type SelectOptions = {
+ /** Catch-all option */
+ other: string
+ [matches: string]: string
+}
+
+/**
+ * Selects a translation based on a value
+ *
+ * Select works like a switch statement. It will
+ * select one of the forms in `options` object which
+ * key matches exactly `value`.
+ *
+ * @example
+ * ```
+ * import { select } from "@lingui/core/macro";
+ * const message = select(gender, {
+ * male: "he",
+ * female: "she",
+ * other: "they",
+ * });
+ * ```
+ *
+ * @param value The key of choices to use
+ * @param choices
+ */
+export function select(value: string, choices: SelectOptions): string
+
+/**
+ * Define a message for later use
+ *
+ * `defineMessage` can be used to add comments for translators,
+ * or to override the message ID.
+ *
+ * @example
+ * ```
+ * import { defineMessage } from "@lingui/core/macro";
+ * const message = defineMessage({
+ * comment: "Greetings on the welcome page",
+ * message: `Welcome, ${name}!`,
+ * });
+ * ```
+ *
+ * @param descriptor The message descriptor
+ */
+export function defineMessage(
+ descriptor: MacroMessageDescriptor
+): MessageDescriptor
+
+/**
+ * Define a message for later use
+ *
+ * @example
+ * ```
+ * import { defineMessage, msg } from "@lingui/core/macro";
+ * const message = defineMessage`Hello ${name}`;
+ *
+ * // or using shorter version
+ * const message = msg`Hello ${name}`;
+ * ```
+ */
+export function defineMessage(
+ literals: TemplateStringsArray,
+ ...placeholders: any[]
+): MessageDescriptor
+
+/**
+ * Define a message for later use
+ * Alias for {@see defineMessage}
+ */
+export const msg: typeof defineMessage
diff --git a/packages/core/macro/index.js b/packages/core/macro/index.js
new file mode 100644
index 000000000..fad7573b3
--- /dev/null
+++ b/packages/core/macro/index.js
@@ -0,0 +1 @@
+module.exports = require("@lingui/babel-plugin-lingui-macro/macro")
diff --git a/packages/core/macro/index.test.ts b/packages/core/macro/index.test.ts
new file mode 100644
index 000000000..d0f728d4f
--- /dev/null
+++ b/packages/core/macro/index.test.ts
@@ -0,0 +1,7 @@
+import macro from "@lingui/core/macro"
+
+describe("react-macro", () => {
+ it("Should re-export Macro", () => {
+ expect((macro as any).isBabelMacro).toBeTruthy()
+ })
+})
diff --git a/packages/core/package.json b/packages/core/package.json
index 9c624cf9d..14cab61b3 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -45,12 +45,20 @@
"default": "./dist/index.mjs"
}
},
+ "./macro": {
+ "require": {
+ "types": "./macro/index.d.ts",
+ "default": "./macro/index.js"
+ }
+ },
"./package.json": "./package.json"
},
"files": [
"LICENSE",
"README.md",
- "dist/"
+ "dist/",
+ "macro/index.d.ts",
+ "macro/index.js"
],
"dependencies": {
"@babel/runtime": "^7.20.13",
@@ -59,6 +67,19 @@
},
"devDependencies": {
"@lingui/jest-mocks": "*",
+ "tsd": "^0.26.1",
"unbuild": "2.0.0"
+ },
+ "peerDependencies": {
+ "@lingui/babel-plugin-lingui-macro": "4.8.0-next.1",
+ "babel-plugin-macros": "2 || 3"
+ },
+ "peerDependenciesMeta": {
+ "@lingui/babel-plugin-lingui-macro": {
+ "optional": true
+ },
+ "babel-plugin-macros": {
+ "optional": true
+ }
}
}
diff --git a/packages/macro/README.md b/packages/macro/README.md
index 8dfd2e450..872810319 100644
--- a/packages/macro/README.md
+++ b/packages/macro/README.md
@@ -24,7 +24,7 @@ See the [reference][reference] documentation.
```jsx
import { setupI18n } from "@lingui/core"
-import { t } from "@lingui/macro"
+import { t } from "@lingui/core/macro"
const i18n = setupI18n()
diff --git a/packages/macro/build.config.ts b/packages/macro/build.config.ts
deleted file mode 100644
index ab91d5fa3..000000000
--- a/packages/macro/build.config.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import { defineBuildConfig } from "unbuild"
-
-export default defineBuildConfig({
- declaration: false,
-})
diff --git a/packages/macro/global.d.ts b/packages/macro/global.d.ts
deleted file mode 100644
index 3473c7249..000000000
--- a/packages/macro/global.d.ts
+++ /dev/null
@@ -1,225 +0,0 @@
-// read more about this file here
-// https://github.com/lingui/js-lingui/issues/936
-// @ts-ignore
-declare module "@lingui/macro" {
- import type { MessageDescriptor, I18n } from "@lingui/core"
-
- type MacroMessageDescriptor = (
- | {
- id: string
- message?: string
- }
- | {
- id?: string
- message: string
- }
- ) & {
- comment?: string
- context?: string
- }
-
- export type BasicType = {
- id?: string
- comment?: string
- }
-
- /**
- * Translates a message descriptor
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * const message = t({
- * id: "msg.hello",
- * comment: "Greetings at the homepage",
- * message: `Hello ${name}`,
- * });
- * ```
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * const message = t({
- * id: "msg.plural",
- * message: plural(value, { one: "...", other: "..." }),
- * });
- * ```
- *
- * @param descriptor The message descriptor to translate
- */
- export function t(descriptor: MacroMessageDescriptor): string
-
- /**
- * Translates a template string using the global I18n instance
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * const message = t`Hello ${name}`;
- * ```
- */
- export function t(
- literals: TemplateStringsArray,
- ...placeholders: any[]
- ): string
-
- /**
- * Translates a template string or message descriptor using a given I18n instance
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * import { I18n } from "@lingui/core";
- * const i18n = new I18n({
- * locale: "nl",
- * messages: { "Hello {0}": "Hallo {0}" },
- * });
- * const message = t(i18n)`Hello ${name}`;
- * ```
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * import { I18n } from "@lingui/core";
- * const i18n = new I18n({
- * locale: "nl",
- * messages: { "Hello {0}": "Hallo {0}" },
- * });
- * const message = t(i18n)({ message: `Hello ${name}` });
- * ```
- */
- export function t(i18n: I18n): {
- (literals: TemplateStringsArray, ...placeholders: any[]): string
- (descriptor: MacroMessageDescriptor): string
- }
-
- export type UnderscoreDigit = { [digit: string]: T }
- export type ChoiceOptions = {
- offset?: number
- zero?: T
- one?: T
- few?: T
- many?: T
- other?: T
- } & UnderscoreDigit
-
- /**
- * Pluralize a message
- *
- * @example
- * ```
- * import { plural } from "@lingui/macro";
- * const message = plural(count, {
- * one: "# Book",
- * other: "# Books",
- * });
- * ```
- *
- * @param value Determines the plural form
- * @param options Object with available plural forms
- */
- export function plural(
- value: number | string,
- options: ChoiceOptions & BasicType
- ): string
-
- /**
- * Pluralize a message using ordinal forms
- *
- * Similar to `plural` but instead of using cardinal plural forms,
- * it uses ordinal forms.
- *
- * @example
- * ```
- * import { selectOrdinal } from "@lingui/macro";
- * const message = selectOrdinal(count, {
- * one: "#st",
- * two: "#nd",
- * few: "#rd",
- * other: "#th",
- * });
- * ```
- *
- * @param value Determines the plural form
- * @param options Object with available plural forms
- */
- export function selectOrdinal(
- value: number | string,
- options: ChoiceOptions & BasicType
- ): string
-
- /**
- * Selects a translation based on a value
- *
- * Select works like a switch statement. It will
- * select one of the forms in `options` object which
- * key matches exactly `value`.
- *
- * @example
- * ```
- * import { select } from "@lingui/macro";
- * const message = select(gender, {
- * male: "he",
- * female: "she",
- * other: "they",
- * });
- * ```
- *
- * @param value The key of choices to use
- * @param choices
- */
- export function select(
- value: string,
- choices: Record & BasicType
- ): string
-
- /**
- * Define a message for later use
- *
- * `defineMessage` can be used to add comments for translators,
- * or to override the message ID.
- *
- * @example
- * ```
- * import { defineMessage } from "@lingui/macro";
- * const message = defineMessage({
- * comment: "Greetings on the welcome page",
- * message: `Welcome, ${name}!`,
- * });
- * ```
- *
- * @param descriptor The message descriptor
- */
- export function defineMessage(
- descriptor: MacroMessageDescriptor
- ): MessageDescriptor
-
- export type ChoiceProps = {
- value?: string | number
- } & ChoiceOptions
-
- /**
- * The types should be changed after this PR is merged
- * https://github.com/Microsoft/TypeScript/pull/26797
- *
- * then we should be able to specify that key of values is same type as value.
- * We would be able to remove separate type Values = {...} definition
- * eg.
- * type SelectProps = {
- * value?: Values
- * [key: Values]: string
- * }
- *
- */
- type Values = { [key: string]: string }
-
- export type SelectProps = {
- value: string
- other: any
- } & Values
-
- export const Trans: any
- export const Plural: any
- export const Select: any
- export const SelectOrdinal: any
-}
diff --git a/packages/macro/index.d.ts b/packages/macro/index.d.ts
index 8c6a84e8d..510eade7b 100644
--- a/packages/macro/index.d.ts
+++ b/packages/macro/index.d.ts
@@ -1,351 +1,8 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
-import type { ReactNode, VFC, FC } from "react"
-import type { I18n, MessageDescriptor } from "@lingui/core"
-import type { TransRenderCallbackOrComponent, I18nContext } from "@lingui/react"
-
-export type ChoiceOptions = {
- /** Offset of value when calculating plural forms */
- offset?: number
- zero?: string
- one?: string
- two?: string
- few?: string
- many?: string
-
- /** Catch-all option */
- other: string
- /** Exact match form, corresponds to =N rule */
- [digit: `${number}`]: string
-}
-
-type MacroMessageDescriptor = (
- | {
- id: string
- message?: string
- }
- | {
- id?: string
- message: string
- }
-) & {
- comment?: string
- context?: string
-}
-
/**
- * Translates a message descriptor
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * const message = t({
- * id: "msg.hello",
- * comment: "Greetings at the homepage",
- * message: `Hello ${name}`,
- * });
- * ```
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * const message = t({
- * id: "msg.plural",
- * message: plural(value, { one: "...", other: "..." }),
- * });
- * ```
- *
- * @param descriptor The message descriptor to translate
+ * @deprecated please use `@lingui/core/macro` directly
*/
-export function t(descriptor: MacroMessageDescriptor): string
-
+export * from "@lingui/core/macro"
/**
- * Translates a template string using the global I18n instance
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * const message = t`Hello ${name}`;
- * ```
+ * @deprecated please use `@lingui/react/macro` directly
*/
-export function t(
- literals: TemplateStringsArray,
- ...placeholders: any[]
-): string
-
-/**
- * Translates a template string or message descriptor using a given I18n instance
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * import { I18n } from "@lingui/core";
- * const i18n = new I18n({
- * locale: "nl",
- * messages: { "Hello {0}": "Hallo {0}" },
- * });
- * const message = t(i18n)`Hello ${name}`;
- * ```
- *
- * @example
- * ```
- * import { t } from "@lingui/macro";
- * import { I18n } from "@lingui/core";
- * const i18n = new I18n({
- * locale: "nl",
- * messages: { "Hello {0}": "Hallo {0}" },
- * });
- * const message = t(i18n)({ message: `Hello ${name}` });
- * ```
- */
-export function t(i18n: I18n): {
- (literals: TemplateStringsArray, ...placeholders: any[]): string
- (descriptor: MacroMessageDescriptor): string
-}
-
-/**
- * Pluralize a message
- *
- * @example
- * ```
- * import { plural } from "@lingui/macro";
- * const message = plural(count, {
- * one: "# Book",
- * other: "# Books",
- * });
- * ```
- *
- * @param value Determines the plural form
- * @param options Object with available plural forms
- */
-export function plural(value: number | string, options: ChoiceOptions): string
-
-/**
- * Pluralize a message using ordinal forms
- *
- * Similar to `plural` but instead of using cardinal plural forms,
- * it uses ordinal forms.
- *
- * @example
- * ```
- * import { selectOrdinal } from "@lingui/macro";
- * const message = selectOrdinal(count, {
- * one: "#st",
- * two: "#nd",
- * few: "#rd",
- * other: "#th",
- * });
- * ```
- *
- * @param value Determines the plural form
- * @param options Object with available plural forms
- */
-export function selectOrdinal(
- value: number | string,
- options: ChoiceOptions
-): string
-
-type SelectOptions = {
- /** Catch-all option */
- other: string
- [matches: string]: string
-}
-
-/**
- * Selects a translation based on a value
- *
- * Select works like a switch statement. It will
- * select one of the forms in `options` object which
- * key matches exactly `value`.
- *
- * @example
- * ```
- * import { select } from "@lingui/macro";
- * const message = select(gender, {
- * male: "he",
- * female: "she",
- * other: "they",
- * });
- * ```
- *
- * @param value The key of choices to use
- * @param choices
- */
-export function select(value: string, choices: SelectOptions): string
-
-/**
- * Define a message for later use
- *
- * `defineMessage` can be used to add comments for translators,
- * or to override the message ID.
- *
- * @example
- * ```
- * import { defineMessage } from "@lingui/macro";
- * const message = defineMessage({
- * comment: "Greetings on the welcome page",
- * message: `Welcome, ${name}!`,
- * });
- * ```
- *
- * @param descriptor The message descriptor
- */
-export function defineMessage(
- descriptor: MacroMessageDescriptor
-): MessageDescriptor
-
-/**
- * Define a message for later use
- *
- * @example
- * ```
- * import { defineMessage, msg } from "@lingui/macro";
- * const message = defineMessage`Hello ${name}`;
- *
- * // or using shorter version
- * const message = msg`Hello ${name}`;
- * ```
- */
-export function defineMessage(
- literals: TemplateStringsArray,
- ...placeholders: any[]
-): MessageDescriptor
-
-/**
- * Define a message for later use
- * Alias for {@see defineMessage}
- */
-export const msg: typeof defineMessage
-
-type CommonProps = TransRenderCallbackOrComponent & {
- id?: string
- comment?: string
- context?: string
-}
-
-type TransProps = {
- children: ReactNode
-} & CommonProps
-
-type PluralChoiceProps = {
- value: string | number
- /** Offset of value when calculating plural forms */
- offset?: number
- zero?: ReactNode
- one?: ReactNode
- two?: ReactNode
- few?: ReactNode
- many?: ReactNode
-
- /** Catch-all option */
- other: ReactNode
- /** Exact match form, corresponds to =N rule */
- [digit: `_${number}`]: ReactNode
-} & CommonProps
-
-type SelectChoiceProps = {
- value: string
- /** Catch-all option */
- other: ReactNode
- [option: `_${string}`]: ReactNode
-} & CommonProps
-
-/**
- * Trans is the basic macro for static messages,
- * messages with variables, but also for messages with inline markup
- *
- * @example
- * ```
- * Hello {username}. Read the docs.
- * ```
- * @example
- * ```
- * Hello {username}.
- * ```
- */
-export const Trans: FC
-
-/**
- * Props of Plural macro are transformed into plural format.
- *
- * @example
- * ```
- * import { Plural } from "@lingui/macro"
- *
- *
- * // ↓ ↓ ↓ ↓ ↓ ↓
- * import { Trans } from "@lingui/react"
- *
- * ```
- */
-export const Plural: VFC
-/**
- * Props of SelectOrdinal macro are transformed into selectOrdinal format.
- *
- * @example
- * ```
- * // count == 1 -> 1st
- * // count == 2 -> 2nd
- * // count == 3 -> 3rd
- * // count == 4 -> 4th
- *
- * ```
- */
-export const SelectOrdinal: VFC
-
-/**
- * Props of Select macro are transformed into select format
- *
- * @example
- * ```
- * // gender == "female" -> Her book
- * // gender == "male" -> His book
- * // gender == "non-binary" -> Their book
- *
- *
- * ```
- */
-export const Select: VFC
-
-export function _t(descriptor: MacroMessageDescriptor): string
-export function _t(
- literals: TemplateStringsArray,
- ...placeholders: any[]
-): string
-
-/**
- *
- * Macro version of useLingui replaces _ function with `t` macro function which is bound to i18n passed from React.Context
- *
- * Returned `t` macro function has all the same signatures as global `t`
- *
- * @example
- * ```
- * const { t } = useLingui();
- * const message = t`Text`;
- * ```
- *
- * @example
- * ```
- * const { i18n, t } = useLingui();
- * const locale = i18n.locale;
- * const message = t({
- * id: "msg.hello",
- * comment: "Greetings at the homepage",
- * message: `Hello ${name}`,
- * });
- * ```
- */
-export function useLingui(): Omit & {
- t: typeof _t
-}
+export * from "@lingui/react/macro"
diff --git a/packages/macro/index.js b/packages/macro/index.js
new file mode 100644
index 000000000..fad7573b3
--- /dev/null
+++ b/packages/macro/index.js
@@ -0,0 +1 @@
+module.exports = require("@lingui/babel-plugin-lingui-macro/macro")
diff --git a/packages/macro/package.json b/packages/macro/package.json
index e9f203e62..9a5cb18ad 100644
--- a/packages/macro/package.json
+++ b/packages/macro/package.json
@@ -2,8 +2,7 @@
"name": "@lingui/macro",
"version": "4.8.0-next.1",
"description": "Macro for generating messages in ICU MessageFormat syntax",
- "main": "./dist/index.cjs",
- "module": "./dist/index.mjs",
+ "main": "./index.cjs",
"types": "./index.d.ts",
"sideEffects": false,
"author": {
@@ -11,9 +10,7 @@
"email": "tomas.ehrlich@gmail.com"
},
"scripts": {
- "test:tsd": "tsd",
- "build": "rimraf ./dist && unbuild",
- "stub": "unbuild --stub"
+ "test:tsd": "tsd"
},
"license": "MIT",
"keywords": [
@@ -40,29 +37,7 @@
".": {
"require": {
"types": "./index.d.ts",
- "default": "./dist/index.cjs"
- },
- "import": {
- "types": "./index.d.ts",
- "default": "./dist/index.mjs"
- }
- },
- "./node": {
- "require": {
- "types": "./dist/index.d.ts"
- },
- "import": {
- "types": "./dist/index.d.ts"
- }
- },
- "./plugin": {
- "require": {
- "types": "./dist/plugin.d.ts",
- "default": "./dist/plugin.cjs"
- },
- "import": {
- "types": "./dist/plugin.d.ts",
- "default": "./dist/index.mjs"
+ "default": "./index.cjs"
}
}
},
@@ -70,31 +45,23 @@
"LICENSE",
"README.md",
"dist/",
- "index.d.ts"
+ "index.d.ts",
+ "index.js"
],
"dependencies": {
- "@babel/core": "7.20.12",
- "@babel/runtime": "^7.20.13",
- "@babel/types": "^7.20.7",
- "@lingui/conf": "4.8.0-next.1",
"@lingui/core": "4.8.0-next.1",
- "@lingui/message-utils": "4.8.0-next.1"
+ "@lingui/react": "4.8.0-next.1"
},
"peerDependencies": {
- "@lingui/react": "^4.0.0",
+ "@lingui/babel-plugin-lingui-macro": "4.8.0-next.1",
"babel-plugin-macros": "2 || 3"
},
"peerDependenciesMeta": {
+ "@lingui/babel-plugin-lingui-macro": {
+ "optional": true
+ },
"babel-plugin-macros": {
"optional": true
}
- },
- "devDependencies": {
- "@babel/parser": "7.20.15",
- "@babel/traverse": "7.20.12",
- "@types/babel-plugin-macros": "^2.8.5",
- "prettier": "2.8.3",
- "tsd": "^0.26.1",
- "unbuild": "2.0.0"
}
}
diff --git a/packages/macro/test/fixtures/js-t-continuation-character.js b/packages/macro/test/fixtures/js-t-continuation-character.js
deleted file mode 100644
index 349a71dad..000000000
--- a/packages/macro/test/fixtures/js-t-continuation-character.js
+++ /dev/null
@@ -1,4 +0,0 @@
-import { t } from '@lingui/macro'
-
-t`Multiline\
- with continuation`
diff --git a/packages/react/macro/__typetests__/index.test-d.tsx b/packages/react/macro/__typetests__/index.test-d.tsx
new file mode 100644
index 000000000..5075b21ab
--- /dev/null
+++ b/packages/react/macro/__typetests__/index.test-d.tsx
@@ -0,0 +1,131 @@
+import { expectType } from "tsd"
+import type { I18n } from "@lingui/core"
+
+import {
+ Trans,
+ Plural,
+ Select,
+ SelectOrdinal,
+ useLingui,
+} from "@lingui/react/macro"
+import React from "react"
+
+const gender = "male"
+let m: any
+
+///////////////////
+//// JSX Trans
+///////////////////
+
+m = Message
+m = (
+
+ Message
+
+)
+
+// @ts-expect-error: children are required here
+m =
+
+///////////////////
+//// JSX Plural
+///////////////////
+m = (
+ // @ts-expect-error: children are not allowed
+
+ Message
+
+)
+
+// @ts-expect-error: value is required
+m =
+
+m =
+
+// @ts-expect-error: offset could be number only
+m =
+
+// @ts-expect-error: not allowed prop is passed
+m =
+
+// should support JSX element as Props
+m = ...} other={...} />
+
+// value as string
+m =
+
+// @ts-expect-error: `other` should always be present
+m =
+
+// additional properties
+m = (
+
+)
+
+///////////////////
+//// JSX SelectOrdinal is the same s Plural, so just smoke test it
+///////////////////
+m = (
+
+)
+
+///////////////////
+//// JSX Select
+///////////////////
+m = (
+ // @ts-expect-error: children are not allowed here
+
+)
+
+// @ts-expect-error: `value` could be string only
+m =
+
+// @ts-expect-error: `other` required
+m =
+
+// @ts-expect-error: `value` required
+m =
+
+m =
+
+// @ts-expect-error: exact cases should be prefixed with underscore
+m =
+
+// should support JSX in props
+m = (
+
}
+ other={