Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(conf): proper typings for LinguiConfig['runtimeConfigModule'] #1329

Merged
merged 1 commit into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/conf/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export declare type LinguiConfig = {
orderBy: OrderBy;
pseudoLocale: string;
rootDir: string;
runtimeConfigModule: [string, string?];
runtimeConfigModule: [source: string, identifier?: string] | {
i18n?: [source: string, identifier?: string]
Trans?: [source: string, identifier?: string]
};
sourceLocale: string;
service: CatalogService;
};
Expand Down Expand Up @@ -77,7 +80,7 @@ export declare const configValidation: {
orderBy: OrderBy;
pseudoLocale: string;
rootDir: string;
runtimeConfigModule: [string, string?];
runtimeConfigModule: LinguiConfig['runtimeConfigModule'];
sourceLocale: string;
service: CatalogService;
};
Expand Down
6 changes: 2 additions & 4 deletions packages/macro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ import MacroJSX from "./macroJsx"

const config = getConfig({ configPath: process.env.LINGUI_CONFIG })

const getSymbolSource = (name: string) => {
const getSymbolSource = (name: 'i18n' | 'Trans'): [source: string, identifier?: string] => {
if (Array.isArray(config.runtimeConfigModule)) {
if (name === "i18n") {
return config.runtimeConfigModule
} else {
return ["@lingui/react", name]
}
} else {
if (
Object.prototype.hasOwnProperty.call(config.runtimeConfigModule, name)
) {
if (config.runtimeConfigModule[name]) {
return config.runtimeConfigModule[name]
} else {
return ["@lingui/react", name]
Expand Down