title | description | date | authors | draft | |
---|---|---|---|---|---|
Known keys |
When you need an object where all the keys are mapped to one type except some known keys that are mapped to different types. |
2024-02-20 |
|
true |
Sources:
- microsoft/TypeScript#31153
- https://github.dev/sindresorhus/type-fest/blob/main/source/merge.d.ts
type MyType = {
[s: string]: string
foo: number
}
When you need an object where all the keys are mapped to one type except some known keys that are mapped to different types.
Why Omit doesn't work:
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
interface FancyIndices {
[x: symbol]: number
[x: `${string}Token`]: string
}
does this work?