@i18n-micro/types 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +6 -4
- package/package.json +1 -1
- package/src/index.ts +12 -9
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ export interface DefineLocaleMessage {
|
|
|
4
4
|
}
|
|
5
5
|
export type TranslationKey = keyof DefineLocaleMessage extends never ? string : keyof DefineLocaleMessage | string;
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* Helper for creating typed prefixes.
|
|
8
|
+
* Allows safe usage of dynamic keys.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```typescript
|
|
12
|
-
* //
|
|
12
|
+
* // Assuming keys: 'errors.404', 'errors.500', 'btn.save'
|
|
13
13
|
* function getErrorText(code: string) {
|
|
14
14
|
* return t(`errors.${code}` as ScopedKey<'errors'>)
|
|
15
15
|
* }
|
|
@@ -57,7 +57,6 @@ export interface ModuleOptions {
|
|
|
57
57
|
autoDetectPath?: string;
|
|
58
58
|
disableWatcher?: boolean;
|
|
59
59
|
types?: boolean;
|
|
60
|
-
includeDefaultLocaleRoute?: boolean;
|
|
61
60
|
routesLocaleLinks?: {
|
|
62
61
|
[key: string]: string;
|
|
63
62
|
};
|
|
@@ -77,6 +76,8 @@ export interface ModuleOptions {
|
|
|
77
76
|
missingWarn?: boolean;
|
|
78
77
|
previousPageFallback?: boolean;
|
|
79
78
|
hmr?: boolean;
|
|
79
|
+
cacheMaxSize?: number;
|
|
80
|
+
cacheTtl?: number;
|
|
80
81
|
experimental?: Record<string, unknown>;
|
|
81
82
|
}
|
|
82
83
|
export interface ModuleOptionsExtend extends ModuleOptions {
|
|
@@ -85,6 +86,7 @@ export interface ModuleOptionsExtend extends ModuleOptions {
|
|
|
85
86
|
isSSG: boolean;
|
|
86
87
|
apiBaseUrl: string;
|
|
87
88
|
disablePageLocales: boolean;
|
|
89
|
+
redirects?: boolean;
|
|
88
90
|
}
|
|
89
91
|
export interface ModulePrivateOptionsExtend extends ModuleOptions {
|
|
90
92
|
rootDir: string;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
export type LocaleCode = string
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// Key registry. Users (via generator) will do module augmentation of this interface.
|
|
4
4
|
export interface DefineLocaleMessage {
|
|
5
5
|
// Module augmentation point - will be extended by @i18n-micro/types-generator
|
|
6
6
|
readonly __augmentation?: never
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
9
|
+
// Key type resolution logic.
|
|
10
|
+
// If the interface is empty (generator not connected), key type is string.
|
|
11
|
+
// If the interface has keys, key type is a union of those keys and string.
|
|
12
|
+
// This allows both strict types (autocomplete) and regular strings (dynamic keys).
|
|
13
13
|
export type TranslationKey = keyof DefineLocaleMessage extends never ? string : keyof DefineLocaleMessage | string
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Helper for creating typed prefixes.
|
|
17
|
+
* Allows safe usage of dynamic keys.
|
|
18
18
|
*
|
|
19
19
|
* @example
|
|
20
20
|
* ```typescript
|
|
21
|
-
* //
|
|
21
|
+
* // Assuming keys: 'errors.404', 'errors.500', 'btn.save'
|
|
22
22
|
* function getErrorText(code: string) {
|
|
23
23
|
* return t(`errors.${code}` as ScopedKey<'errors'>)
|
|
24
24
|
* }
|
|
@@ -74,7 +74,7 @@ export interface ModuleOptions {
|
|
|
74
74
|
autoDetectPath?: string
|
|
75
75
|
disableWatcher?: boolean
|
|
76
76
|
types?: boolean
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
routesLocaleLinks?: { [key: string]: string }
|
|
79
79
|
plural?: string | PluralFunc
|
|
80
80
|
disablePageLocales?: boolean
|
|
@@ -92,6 +92,8 @@ export interface ModuleOptions {
|
|
|
92
92
|
missingWarn?: boolean
|
|
93
93
|
previousPageFallback?: boolean
|
|
94
94
|
hmr?: boolean
|
|
95
|
+
cacheMaxSize?: number
|
|
96
|
+
cacheTtl?: number
|
|
95
97
|
experimental?: Record<string, unknown>
|
|
96
98
|
}
|
|
97
99
|
|
|
@@ -101,6 +103,7 @@ export interface ModuleOptionsExtend extends ModuleOptions {
|
|
|
101
103
|
isSSG: boolean
|
|
102
104
|
apiBaseUrl: string
|
|
103
105
|
disablePageLocales: boolean
|
|
106
|
+
redirects?: boolean
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
export interface ModulePrivateOptionsExtend extends ModuleOptions {
|