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

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;
}
doc_TypeScript
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.