Objects with Properties

Objects with Properties

Documentation

The global variable myLib has a function makeGreeting for creating greetings, and a property numberOfGreetings indicating the number of greetings made so far.

Code

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.

declare namespace myLib {
  function makeGreeting(s: string): string;
  let numberOfGreetings: number;
}
doc_TypeScript
2016-10-04 19:25:28
Comments
Leave a Comment

Please login to continue.