TypeScript

​​JavaScript that scales

卢涛南 Randy

twitter: @randyloop

weibo: @米斯特软的

Github: djyde

http://lutaonan.com

What's wrong with JavaScript

in application that scales

What's wrong with JavaScript

We know less and less

about our data

const { title, members } = this.request.body

But, what `members` means?

Refactor

Self Documenting

Interface

The shape of your object

Type Checking

let age = 21
age = '22' // Error
{
  "id": "undefined",
  "title": "Breaking News"
}

WTF is "undefiend"?

{
  "title": "Breaking news",
  "author": "Clark Kent",
  "content": "<div><img src=\"foo.jpg\" data-title=\"foo\" /></div>",
  "image": [
    {
      "src": "foo.jpg",
      "title": "foo"
    }
  ]
}

Node.js

Java

ES6/7 Superset

ES7 features, now!

  • async/await
  • decorators

Work with

third-party library

$ npm i @types/xxx

Thanks

twitter: @randyloop

weibo: @米斯特软的

Github: djyde

http://lutaonan.com

TypeScript presentation

By Randy Lu

TypeScript presentation

  • 1,108
Loading comments...

More from Randy Lu