Quick Migration to TypeScript

What is TypeScript

Why TypeScript?

Autocomplete

Type Checking

The future of web development

Definition Files

// lib.d.ts

declare function parseInt(s: string, radix?: number): number;

declare function encodeURI(uri: string): string;

interface Object {
  constructor: Function;
  toString(): string;
  hasOwnProperty(v: string): boolean;
  isPrototypeOf(v: Object): boolean;
  ...
}

TypeScript Definition Manager

# Install Typings CLI utility.
npm install typings --global

# Install typings.
typings install lodash --save

TypeScript is Superset

TypeScript is Superset

var foo = {};
foo.bar = '';

Time to Say Goodbye?

allowJs

Step 1: Build Process

Step 2: Choose Component

ES6 Module

typings install

Interfaces

Add Types

Common Pitfalls

// service.ts
module.exports = function() {
    ...
}
// index.ts
import service from './service';

Common Pitfalls

import styles from './styles.css';
import template from './template.html';
var styles = require('./styles.css');
var template = require('./template.html');

You Can Start Tomorrow

Thank you!

Quick Migration to TypeScript

By Itay Radotzki

Quick Migration to TypeScript

  • 304