Objects with Properties
Documentation
The global variable
myLib
has a functionmakeGreeting
for creating greetings, and a propertynumberOfGreetings
indicating the number of greetings made so far.
Code
1 2 3 4 | let result = myLib.makeGreeting( "hello, world" ); console.log( "The computed greeting is:" + result); let count = myLib.numberOfGreetings; |
Declaration
Use declare namespace
to describe types or values accessed by dotted notation.
1 2 3 4 | declare namespace myLib { function makeGreeting(s: string): string; let numberOfGreetings: number; } |
Please login to continue.