Skip to content

Commit

Permalink
fix(conf) proper typings for LinguiConfig['runtimeConfigModule'] (#1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko authored Jan 10, 2023
1 parent 557caa7 commit 389bb85
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

1 comment on commit 389bb85

@vercel
Copy link

@vercel vercel bot commented on 389bb85 Jan 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

js-lingui – ./

js-lingui.vercel.app
lingui.js.org
js-lingui-lingui.vercel.app
js-lingui-git-main-lingui.vercel.app

Please sign in to comment.