How can I remove a wider type from a union type without removing its subtypes in TypeScript?
Current solution (Typescript 4.1+) 2021 Edit: The 2.8 implementation of KnownKeys<T> is broken since Typescript 4.3.1-rc, but a new, more semantic implementation using key remapping is available since 4.1: type RemoveIndex<T> = { [ K in keyof T as string extends K ? never : number extends K ? never : K ] : T[K] … Read more