I am struggling with removing properties in TypeScript.
type Person<GN> = {
getName: GN extends never ? never : GN,
}
const foo = <GN>(person: Person<GN>) => person
const first = foo({}) // This should work
const second = foo({
getName: (name: string) => name,
})
In the first case, there is no need for the getName property. How can I address this issue?
If I use an optional '?' property, the output becomes unclear.
type Person<GN> = {
getName?: GN,
}
const foo = <GN>(person: Person<GN>) => person
const first = foo({}) // This should work
first.getName // 'getName' shouldn't exist but it does
const second = foo({
getName: (name: string) => name,
})
second.getName // 'getName' should exist as an optional property
How can I achieve a clear output? Thank you for your help.