Skip to content

Commit 087ec1f

Browse files
authored
fix: compilerBabelOptions warning with jest-validate (#938)
1 parent 8631111 commit 087ec1f

4 files changed

Lines changed: 21 additions & 8 deletions

File tree

packages/cli/src/api/compile.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as t from "@babel/types"
2-
import generate from "@babel/generator"
2+
import generate, { GeneratorOptions } from "@babel/generator"
33
import { parse } from "messageformat-parser"
44
import * as R from "ramda"
55

@@ -15,7 +15,7 @@ export type CreateCompileCatalogOptions = {
1515
strict?: boolean
1616
namespace?: CompiledCatalogNamespace
1717
pseudoLocale?: string
18-
compilerBabelOptions?: Record<string, unknown>
18+
compilerBabelOptions?: GeneratorOptions
1919
}
2020

2121
export function createCompiledCatalog(

packages/conf/index.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { GeneratorOptions } from "@babel/core";
2+
13
export declare type CatalogFormat = "lingui" | "minimal" | "po" | "csv" | "po-gettext";
24
export type CatalogFormatOptions = {
35
origins?: boolean;
@@ -24,7 +26,7 @@ export declare type LinguiConfig = {
2426
catalogs: CatalogConfig[];
2527
compileNamespace: string;
2628
extractBabelOptions: Record<string, unknown>;
27-
compilerBabelOptions: Record<string, unknown>;
29+
compilerBabelOptions: GeneratorOptions;
2830
fallbackLocales: FallbackLocales;
2931
format: CatalogFormat;
3032
prevFormat: CatalogFormat;
@@ -52,7 +54,7 @@ export declare const configValidation: {
5254
plugins: string[];
5355
presets: string[];
5456
};
55-
compilerBabelOptions: Record<string, unknown>;
57+
compilerBabelOptions: GeneratorOptions;
5658
catalogs: CatalogConfig[];
5759
compileNamespace: string;
5860
fallbackLocales: FallbackLocales;

packages/conf/src/__snapshots__/index.test.ts.snap

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,12 @@ Object {
110110
],
111111
catalogsMergePath: ,
112112
compileNamespace: cjs,
113-
compilerBabelOptions: Object {},
113+
compilerBabelOptions: Object {
114+
jsescOption: Object {
115+
minimal: true,
116+
},
117+
minified: true,
118+
},
114119
extractBabelOptions: Object {
115120
plugins: Array [],
116121
presets: Array [],

packages/conf/src/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { GeneratorOptions } from "@babel/core"
12
import path from "path"
23
import fs from "fs"
34
import chalk from "chalk"
@@ -34,7 +35,7 @@ export type LinguiConfig = {
3435
catalogs: CatalogConfig[]
3536
compileNamespace: string
3637
extractBabelOptions: Record<string, unknown>
37-
compilerBabelOptions: Record<string, unknown>
38+
compilerBabelOptions: GeneratorOptions
3839
fallbackLocales?: FallbackLocales
3940
format: CatalogFormat
4041
formatOptions: CatalogFormatOptions
@@ -66,7 +67,12 @@ export const defaultConfig: LinguiConfig = {
6667
],
6768
catalogsMergePath: "",
6869
compileNamespace: "cjs",
69-
compilerBabelOptions: {},
70+
compilerBabelOptions: {
71+
minified: true,
72+
jsescOption: {
73+
minimal: true,
74+
}
75+
},
7076
extractBabelOptions: { plugins: [], presets: [] },
7177
fallbackLocales: {},
7278
format: "po",
@@ -266,7 +272,7 @@ export function replaceRootDir(
266272
} else if (typeof value === "string") {
267273
return replace(value)
268274
} else if (Array.isArray(value)) {
269-
return value.map((item) => replaceDeep(item, rootDir)) as any
275+
return (value as any).map((item) => replaceDeep(item, rootDir))
270276
} else if (typeof value === "object") {
271277
Object.keys(value).forEach((key) => {
272278
const newKey = replaceDeep(key, rootDir)

0 commit comments

Comments
 (0)