Skip to content

Commit d870407

Browse files
authored
docs: fix incomplete Records example (#2579)
1 parent ab8e717 commit d870407

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,12 @@ type NumberCache = z.infer<typeof NumberCache>;
15251525
This is particularly useful for storing or caching items by ID.
15261526

15271527
```ts
1528+
const userSchema = z.object({ name: z.string() });
1529+
const userStoreSchema = z.record(userSchema);
1530+
1531+
type UserStore = z.infer<typeof userStoreSchema>;
1532+
// => type UserStore = { [ x: string ]: { name: string } }
1533+
15281534
const userStore: UserStore = {};
15291535

15301536
userStore["77d2586b-9e8e-4ecf-8b21-ea7e0530eadd"] = {

README_ZH.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,12 @@ type NumberCache = z.infer<typeof NumberCache>;
845845
这对于按 ID 存储或缓存项目特别有用。
846846

847847
```ts
848+
const userSchema = z.object({ name: z.string() });
849+
const userStoreSchema = z.record(userSchema);
850+
851+
type UserStore = z.infer<typeof userStoreSchema>;
852+
// => type UserStore = { [ x: string ]: { name: string } }
853+
848854
const userStore: UserStore = {};
849855

850856
userStore["77d2586b-9e8e-4ecf-8b21-ea7e0530eadd"] = {

deno/lib/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,12 @@ type NumberCache = z.infer<typeof NumberCache>;
15241524
This is particularly useful for storing or caching items by ID.
15251525

15261526
```ts
1527+
const userSchema = z.object({ name: z.string() });
1528+
const userStoreSchema = z.record(userSchema);
1529+
1530+
type UserStore = z.infer<typeof userStoreSchema>;
1531+
// => type UserStore = { [ x: string ]: { name: string } }
1532+
15271533
const userStore: UserStore = {};
15281534

15291535
userStore["77d2586b-9e8e-4ecf-8b21-ea7e0530eadd"] = {

0 commit comments

Comments
 (0)