TypeScript

A superset of JavaScript with typing.

www.typescriptlang.org


Richard Stromer
www.noxan.net

Agenda

  • What is TypeScript?
  • Why should I use TypeScript?
  • Typings and definition files
  • Tooling
  • Getting started
  • Credits and links

What is TypeScript?

A language for large scale JavaScript development.

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.

Any browser. Any host. Any OS. Open source.

github.com/Microsoft/TypeScript

Why should I use TypeScript?

Design goals of TypeScript

Statically identify constructs that are likely to be errors.

Like improved linting & errors before you run any code.

Provide a structuring mechanism for larger pieces of code.

Module system, interfaces, imports

Align with current and future ECMAScript proposals.

Classes, arrow functions, annotations...

Preserve runtime behavior of all JavaScript code.

And the output is human readable.

Any JavaScript code is valid TypeScript.

So just rename your file and get started.

Tooling and developer support.

Helps you to get your job done.

And it keeps growing

Google Trends

Typings and definition files

Definition file

/// < reference path="es6-shim.d.ts" / >

declare var MyPoint: {
  x: number;
  y: number;
};

lib.d.ts

Typings for JavaScript (~714KB).

Typings

The simple way to manage and install TypeScript definitions.

github.com/typings

Using typings

// Install Typings CLI utility.
$ npm install typings --global

// Search for definitions.
$ typings search react

// Install typings
$ typings install react

Quick start

Tooling

Tooling support

  • Static type checking
  • Symbol-based navigation
  • Code completion
  • Code refactoring

Editor support

  • Visual Studio (Code)
  • Sublime Text
  • Vim
  • Emacs
  • WebStorm
  • Atom
  • Eclipse
  • And many more...

Tslint

An extensible linter for the TypeScript language.

github.com/palantir/tslint

Getting started

// Install
npm install -g typescript

// Compile
tsc helloworld.ts

Tutorials

www.typescriptlang.org/docs/tutorial.html

github.com/TypeStrong/learn-typescript

Demo time?

www.typescriptlang.org/play

Questions?

Credits and links