typescript type alias, the document has an example:
type Name = string;
type NameResolver = () => string; //
type NameOrResolver = Name | NameResolver;
function getName(n: NameOrResolver): Name {
if (typeof n === "string") {
return n;
} else {
return n();
}
}
question:
What does the statement on the second line ofmean? Please help me explain. Thank you