Organizing Types
Documentation
The
greeter
object can log to a file or display an alert. You can provide LogOptions to.log(...)
and alert options to.alert(...)
Code
1 2 3 | const g = new Greeter( "Hello" ); g.log({ verbose: true }); g.alert({ modal: false , title: "Current Greeting" }); |
Declaration
Use namespaces to organize types.
1 2 3 4 5 6 7 8 9 10 | declare namespace GreetingLib { interface LogOptions { verbose?: boolean; } interface AlertOptions { modal: boolean; title?: string; color?: string; } } |
You can also created nested namespaces in one declaration:
1 2 3 4 5 6 7 8 9 10 11 | declare namespace GreetingLib.Options { // Refer to via GreetingLib.Options.Log interface Log { verbose?: boolean; } interface Alert { modal: boolean; title?: string; color?: string; } } |
Please login to continue.