Reusable Types (Interfaces)
Documentation
When specifying a greeting, you must pass a
GreetingSettingsobject. This object has the following properties: - greeting: Mandatory string - duration: Optional length of time (in milliseconds) - color: Optional string, e.g. ‘#ff00ff’
Code
greet({
greeting: "hello world",
duration: 4000
});
Declaration
Use an interface to define a type with properties.
interface GreetingSettings {
greeting: string;
duration?: number;
color?: string;
}
declare function greet(setting: GreetingSettings): void;
Please login to continue.