Skip to content

Commit

Permalink
fix(conf) proper typings for LinguiConfig['runtimeConfigModule']
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko committed Jan 10, 2023
1 parent 2f500a9 commit 17932d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
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

0 comments on commit 17932d4

Please sign in to comment.