File tree 3 files changed +18
-0
lines changed
3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1525,6 +1525,12 @@ type NumberCache = z.infer<typeof NumberCache>;
1525
1525
This is particularly useful for storing or caching items by ID.
1526
1526
1527
1527
``` 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
+
1528
1534
const userStore: UserStore = {};
1529
1535
1530
1536
userStore [" 77d2586b-9e8e-4ecf-8b21-ea7e0530eadd" ] = {
Original file line number Diff line number Diff line change @@ -845,6 +845,12 @@ type NumberCache = z.infer<typeof NumberCache>;
845
845
这对于按 ID 存储或缓存项目特别有用。
846
846
847
847
``` 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
+
848
854
const userStore: UserStore = {};
849
855
850
856
userStore [" 77d2586b-9e8e-4ecf-8b21-ea7e0530eadd" ] = {
Original file line number Diff line number Diff line change @@ -1524,6 +1524,12 @@ type NumberCache = z.infer<typeof NumberCache>;
1524
1524
This is particularly useful for storing or caching items by ID.
1525
1525
1526
1526
``` 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
+
1527
1533
const userStore: UserStore = {};
1528
1534
1529
1535
userStore [" 77d2586b-9e8e-4ecf-8b21-ea7e0530eadd" ] = {
You can’t perform that action at this time.
0 commit comments