We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e7b32da commit e59b0d3Copy full SHA for e59b0d3
README.md
@@ -83,6 +83,29 @@ Overflow text
83
- Corepack for nodejs
84
- Object.groupBy, Map.groupBy
85
86
+### Typescript
87
+- Union type
88
+```typescript
89
+const obj = {
90
+ '1': 'apple',
91
+ '2': 'banana',
92
+ '3': 'cherry',
93
+} as const satisfies Record<string, string>;
94
+
95
+type KeyUnion = keyof typeof apiData; // '1' | '2' | '3'
96
+type ValueUnion = typeof apiData[keyof typeof apiData]; // 'apple' | 'banana' | 'cherry'
97
+```
98
99
100
+ '1': 'a',
101
+ '2': 'b',
102
+ '3': 'c',
103
+} as const;
104
105
+type KeyUnion = keyof typeof obj; // '1' | '2' | '3'
106
+type ValueUnion = typeof obj[keyof typeof obj]; // 'a' | 'b' | 'c'
107
108
109
### React
110
- Event type quick
111
```typescript
0 commit comments