Anywhere a greeting is expected, you can provide a string, a function returning a string, or a Greeter instance.
Code:
function getGreeting() {
return "howdy";
}
class MyGreeter extends Greeter { }
greet("hello");
greet(getGreeting);
greet(new MyGreeter());
Declaration:
type GreetingLike = string | (() => string) | MyGreeter;
declare function greet(g: GreetingLike): void;
In order to match the documentation requirements, the first line of that declaration should be revised to:
type GreetingLike = string | (() => string) | Greeter;
https://www.typescriptlang.org/docs/handbook/declaration-files/by-example.html#reusable-types-type-aliases
Documentation:
Code:
Declaration:
In order to match the documentation requirements, the first line of that declaration should be revised to:
type GreetingLike = string | (() => string) | Greeter;