How to define an Omit < Source, Exclude extends keyof Source > generic type in typescript

how to define an Omit < SourceType, ExcludeProps extends keyof SourceType > generic type so that

  1. attribute with no key value in ExcludeProps in the result type
  2. there are attributes in the result type whose optional attribute is consistent with SourceType

I have several attempts as follows

".
  Property "c" is missing in type "TargetType".
Mar.12,2021

try:


type Omit<A, B extends keyof A> = Pick<A, ({
  [K in keyof A]: K
} & {
  [K in B]: never
})[keyof A]>
Menu