TypeScript is a typed superset of JavaScript created by Microsoft that adds optional types, classes, async/await, and many other features, and compiles to plain JavaScript. Angular built entirely in TypeScript and used as a primary language. You can install it globally as
1 | npm install -g typescript |
Let’s see a simple example of TypeScript usage:
1 2 3 4 5 6 7 | function greeter(person: string) { return "Hello, " + person; } let user = "Prem"; document.body.innerHTML = greeter(user); |
The greeter method allows only string type as argument.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.