@verbaly/compiler 0.69.0 → 0.69.1
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 +3 -2
- package/dist/cli.js +16 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -119,11 +119,12 @@ Every `t` your project holds checks its keys and their params: the one from `vir
|
|
|
119
119
|
```ts
|
|
120
120
|
const t = useT();
|
|
121
121
|
t('settings.save'); // ✓
|
|
122
|
-
t('settings.sav'); // ✗ '"settings.sav"' is not assignable to parameter of type '
|
|
122
|
+
t('settings.sav'); // ✗ '"settings.sav"' is not assignable to parameter of type 'VerbalyKey'
|
|
123
123
|
t('greeting'); // ✗ greeting is "Hello {name}", so it asks for { name }
|
|
124
|
+
t(item.key); // ✓ a key that comes from data passes as it is
|
|
124
125
|
```
|
|
125
126
|
|
|
126
|
-
A key that comes from data
|
|
127
|
+
A key you write is checked, through a `const` or a template of literals too. A key that comes from data, a `string` or a template with a part from data like ``t(`status.${s}`)``, passes as it is, since no catalog can tell which key it will be. Declare such keys with `defineKeys` (above) when you want `check` to verify they exist and `--prune` to keep them.
|
|
127
128
|
|
|
128
129
|
The types are one generated file, written where your framework's TypeScript already reads, so there is nothing to add to `tsconfig.json`:
|
|
129
130
|
|
package/dist/cli.js
CHANGED
|
@@ -2289,11 +2289,22 @@ ${lines.join("\n")}
|
|
|
2289
2289
|
): import('verbaly').Verbaly;
|
|
2290
2290
|
export function createRequestInstance(locale: string): Promise<import('verbaly').Verbaly>;
|
|
2291
2291
|
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
?
|
|
2296
|
-
:
|
|
2292
|
+
// a key written as a literal must exist; string, or a template with a part from data, is data
|
|
2293
|
+
export function t<K extends VerbalyKey | TemplateStringsArray | (string & {})>(
|
|
2294
|
+
first: K extends TemplateStringsArray
|
|
2295
|
+
? K
|
|
2296
|
+
: {} extends Record<K & string, 1>
|
|
2297
|
+
? K
|
|
2298
|
+
: K extends VerbalyKey ? K : VerbalyKey,
|
|
2299
|
+
...rest: [K] extends [never]
|
|
2300
|
+
? [params?: import('verbaly').Params]
|
|
2301
|
+
: K extends TemplateStringsArray
|
|
2302
|
+
? unknown[]
|
|
2303
|
+
: {} extends Record<K & string, 1>
|
|
2304
|
+
? [params?: import('verbaly').Params]
|
|
2305
|
+
: K extends VerbalyKey
|
|
2306
|
+
? [VerbalyMessages[K]] extends [never] ? [] : [VerbalyMessages[K]]
|
|
2307
|
+
: unknown[]
|
|
2297
2308
|
): string;
|
|
2298
2309
|
export namespace t {
|
|
2299
2310
|
export function id(
|