#Very simple question about generics and unions
1 messages · Page 1 of 1 (latest)
Or in this context:
export interface PluginInstance<
Settings extends GenericSettings | undefined = GenericSettings | undefined,
> {
// bla bla bla
}
that's a default for the generic
type X<T = "a"> = T;
type Y = X<number>;
// ^? - type Y = number
type Z = X;
// ^? - type Z = "a"
kinda like how you do function argument defaults
it says undefined = GenericSettings, and undefined is a standard type / value
In your example T isnt like undefined
Wouldn't that just return
true?
remember, equality checks are==in most programming languages
oh right
that's a generic named Settings, constrained to GenericSettings | undefined, defaulted to GenericSettings | undefined
Settings
extends GenericSettings | undefined
= GenericSettings | undefined
so this is Settings, which extends GenericSettings | undefined, but is defaulted to undefined
correct