Skip to content

Commit

Permalink
fix: compilerBabelOptions warning with jest-validate (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
semoal authored Jan 13, 2021
1 parent 8631111 commit 087ec1f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/api/compile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from "@babel/types"
import generate from "@babel/generator"
import generate, { GeneratorOptions } from "@babel/generator"
import { parse } from "messageformat-parser"
import * as R from "ramda"

Expand All @@ -15,7 +15,7 @@ export type CreateCompileCatalogOptions = {
strict?: boolean
namespace?: CompiledCatalogNamespace
pseudoLocale?: string
compilerBabelOptions?: Record<string, unknown>
compilerBabelOptions?: GeneratorOptions
}

export function createCompiledCatalog(
Expand Down
6 changes: 4 additions & 2 deletions packages/conf/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { GeneratorOptions } from "@babel/core";

export declare type CatalogFormat = "lingui" | "minimal" | "po" | "csv" | "po-gettext";
export type CatalogFormatOptions = {
origins?: boolean;
Expand All @@ -24,7 +26,7 @@ export declare type LinguiConfig = {
catalogs: CatalogConfig[];
compileNamespace: string;
extractBabelOptions: Record<string, unknown>;
compilerBabelOptions: Record<string, unknown>;
compilerBabelOptions: GeneratorOptions;
fallbackLocales: FallbackLocales;
format: CatalogFormat;
prevFormat: CatalogFormat;
Expand Down Expand Up @@ -52,7 +54,7 @@ export declare const configValidation: {
plugins: string[];
presets: string[];
};
compilerBabelOptions: Record<string, unknown>;
compilerBabelOptions: GeneratorOptions;
catalogs: CatalogConfig[];
compileNamespace: string;
fallbackLocales: FallbackLocales;
Expand Down
7 changes: 6 additions & 1 deletion packages/conf/src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ Object {
],
catalogsMergePath: ,
compileNamespace: cjs,
compilerBabelOptions: Object {},
compilerBabelOptions: Object {
jsescOption: Object {
minimal: true,
},
minified: true,
},
extractBabelOptions: Object {
plugins: Array [],
presets: Array [],
Expand Down
12 changes: 9 additions & 3 deletions packages/conf/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { GeneratorOptions } from "@babel/core"
import path from "path"
import fs from "fs"
import chalk from "chalk"
Expand Down Expand Up @@ -34,7 +35,7 @@ export type LinguiConfig = {
catalogs: CatalogConfig[]
compileNamespace: string
extractBabelOptions: Record<string, unknown>
compilerBabelOptions: Record<string, unknown>
compilerBabelOptions: GeneratorOptions
fallbackLocales?: FallbackLocales
format: CatalogFormat
formatOptions: CatalogFormatOptions
Expand Down Expand Up @@ -66,7 +67,12 @@ export const defaultConfig: LinguiConfig = {
],
catalogsMergePath: "",
compileNamespace: "cjs",
compilerBabelOptions: {},
compilerBabelOptions: {
minified: true,
jsescOption: {
minimal: true,
}
},
extractBabelOptions: { plugins: [], presets: [] },
fallbackLocales: {},
format: "po",
Expand Down Expand Up @@ -266,7 +272,7 @@ export function replaceRootDir(
} else if (typeof value === "string") {
return replace(value)
} else if (Array.isArray(value)) {
return value.map((item) => replaceDeep(item, rootDir)) as any
return (value as any).map((item) => replaceDeep(item, rootDir))
} else if (typeof value === "object") {
Object.keys(value).forEach((key) => {
const newKey = replaceDeep(key, rootDir)
Expand Down

1 comment on commit 087ec1f

@vercel
Copy link

@vercel vercel bot commented on 087ec1f Jan 13, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.