File tree Expand file tree Collapse file tree 6 files changed +18
-12
lines changed
Expand file tree Collapse file tree 6 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,11 @@ export function getFallbackListForLocale(
1111 Array . isArray ( mapping ) ? fL . push ( ...mapping ) : fL . push ( mapping )
1212 }
1313
14- if ( fallbackLocales ?. default && locale !== fallbackLocales ?. default ) {
15- fL . push ( fallbackLocales ?. default )
14+ if (
15+ typeof fallbackLocales ?. default === "string" &&
16+ locale !== fallbackLocales ?. default
17+ ) {
18+ fL . push ( fallbackLocales . default )
1619 }
1720
1821 return fL
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ import { makeConfig } from "./makeConfig"
66import { createJiti } from "jiti"
77import pico from "picocolors"
88
9- function configExists ( path : string ) {
10- return path && fs . existsSync ( path )
9+ function configExists ( path ? : string ) : path is string {
10+ return ! ! path && fs . existsSync ( path )
1111}
1212
1313function JitiLoader ( ) : LoaderSync {
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ export function setCldrParentLocales(
1010 } as unknown as LinguiConfigNormalized
1111 }
1212
13- if ( ! config . fallbackLocales . default ) {
13+ if ( ! config . fallbackLocales ? .default ) {
1414 config . locales . forEach ( ( locale ) => {
1515 const fl = getCldrParentLocale ( locale . toLowerCase ( ) )
1616 if ( fl && ! ( config . fallbackLocales as FallbackLocales ) [ locale ] ) {
Original file line number Diff line number Diff line change @@ -106,10 +106,11 @@ export type CatalogConfig = {
106106 exclude ?: string [ ]
107107}
108108
109- type LocaleObject = {
110- [ locale : string ] : string [ ] | string
111- default ?: string
112- }
109+ type LocaleObject =
110+ | Record < string , string [ ] | string >
111+ | ( Record < string , string [ ] | string > & {
112+ default : string
113+ } )
113114
114115export type FallbackLocales = LocaleObject
115116
@@ -257,7 +258,7 @@ export type LinguiConfig = {
257258 *
258259 * Note that using <rootDir> as a string token in any other path-based config settings will refer back to this value.
259260 *
260- * @defaul : The root of the directory containing your Lingui configuration file or the package.json.
261+ * @default : The root of the directory containing your Lingui configuration file or the package.json.
261262 */
262263 rootDir ?: string
263264 /**
Original file line number Diff line number Diff line change @@ -2,8 +2,11 @@ import { LinguiConfig } from "../types"
22
33export function replaceRootDir < T extends Partial < LinguiConfig > > (
44 config : T ,
5- rootDir : string
5+ rootDir : string | undefined
66) : T {
7+ if ( ! rootDir ) {
8+ return config
9+ }
710 return ( function replaceDeep ( value : any , rootDir : string ) : any {
811 const replace = ( s : string ) => s . replace ( "<rootDir>" , rootDir )
912
Original file line number Diff line number Diff line change 1010 "resolveJsonModule" : true ,
1111 "skipLibCheck" : true ,
1212 "strict" : true ,
13- "strictNullChecks" : false
1413 },
1514 "files" : [
1615 " ./src/index.ts"
You can’t perform that action at this time.
0 commit comments