Using TypeScript

TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.
— TypeScript Website

Nowadays, there are very few reasons not to use TypeScript (TS). It allows to work as fast as with JavaScript and offers the needed structure to grow a projet at scale.

Getting Started with TS

As you code, autocompletions and type errors will appear to help you out.

TypeScript autocomplete TypeScript error TypeScript error 2

Example

// index.ts

type Foo = {
    bar: string
}

function giveMeFoo(): Foo {
    return {
        bar: "baz"
    }
}

const x = giveMeFoo();
   // ^ type Foo

const y = x.bar;
   // ^ type string