Typescript type alias

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 of

mean? Please help me explain. Thank you

Jul.14,2021

declares a function type, and the return value is string

Menu