type User = {
name?:string
age?:number
sex?:string
}
type MyOmit<T,K extends PropertyKey> = {[P in ExClude<keyof T, K>]:T[P]}
type A = MyOmit<User,'name'|'age'>
type B = Omit<User,'name'|'age'>
Why type A = {sex:string|undefined}
and type B = {sex?:string|undefined}
? The underlying processing method of Omit type tools is MyOmit. Why do the results differ?
New contributor
mengjie guo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.