TypeScript is an object-oriented language designed by Microsoft.
TypeScript is a superset of JavaScript that offers all of JavaScript’s features and TypeScript’s type system.
In this shot, we will see how to write a simple “Hello World” program in TypeScript.
In this example, we declare a variable message
of type string
, and initialize it to ‘Hello World’. Unlike JavaScript, TypeScript is string
.
// Declare and initialize 'message' of type string // to 'Hello World'. let message: string = 'Hello World'; // Printing the message to console. console.log(message);
TypeScript also supports type inference and will generate types in many cases.
In the example above, you can skip writing the type
(let message = 'Hello World';
),
and TypeScript will correctly infer the type asstring
.
RELATED TAGS
CONTRIBUTOR
View all Courses