Type that omits all inherited properties?
Say we have I want a type that incudes only the fields from Child without the inherited properties.
For example,
type OnlyChild = { play: () => void }
. Is that possible. I know I can use Omit<> but I don't know what the properties of Person are.3 Replies
wait
type OnlyNonInherited = Omit<B, keyof A>;
maybe?
Except I don't know AUnknown User•3y ago
Message Not Public
Sign In & Join Server To View
If you think about types like types instead of interfaces they will extend each other by doing
type B = A & {bProp: any}
, so in that syntax compared to the actual extend
one used in interfaces, you can see it's pretty much just a concatenation of multiple types, not a layering.
Therefore I think this might not be possible.
May I ask you for the purpose of that? There might be a different approach doing what you're aiming for