Does TypeScript have an analogue of `keyof` for getting object value types?
Hi everyone! I just started learning TypeScript and ran into a situation. I know that the `keyof` operator allows you to get a union of object keys. For example, if I have a `User` interface, then `keyof User` returns the type `"id" | "name" | "email"`. This is very convenient.\n\nBut I need to do the opposite: get the type of object values. Let's say I have a configuration:\n\n```typescript\nconst appConfig = {\n apiUrl: 'https://api.example.com',\n port: 3000,\n debug: true\n};\n```\n\nI want to create a type that represents all possible values from this object, i.e. `string | number | boolean`. In a real project, I might have 20+ fields with different types, and listing them manually is terrible.\n\nI tried something like `valueof typeof appConfig`, but TypeScript out
No answers yet.
Log in to leave an answer