Introduction

Welcome to our first lesson on TypeScript, a superset of JavaScript that adds static types to the language. TypeScript has garnered widespread appreciation for its ability to catch errors early through its type system and to make JavaScript development more robust and maintainable. Today, we will embark on an exciting journey into the basics of TypeScript. By the end of this lesson, you'll have a solid understanding of TypeScript syntax, how to write comments, the role of indentation, and how to use the console.log() function to display messages.

Understanding TypeScript Syntax

Syntax refers to the set of rules that defines the combinations of symbols that are considered to be correctly structured programs in a programming language. TypeScript builds on JavaScript's syntax, adding optional static typing. Let's start with something very simple:

Here, console.log() is a method that TypeScript (and JavaScript) provides to output the provided input to the console, and "Hello, and welcome to the TypeScript World!" is a string that gets printed on the console.

Explaining Comments in TypeScript

Comments in code are like notes you might scribble in the margins of a book; they can explain what's happening, why a piece of code was written a certain way, or even specify tasks to be done later. TypeScript inherits its commenting syntax from JavaScript:

In the given TypeScript code snippet, you see a single-line comment starting with //, and a block of lines enclosed within and , forming a multi-line comment.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal