https://github.com/microsoft/TypeScript-New-Handbook/blob/master/intros/TypeScript for the Haskell or ML Programmer.md
TypeScript began its life as an attempt to bring traditional object-oriented types to JavaScript so that the programmers at Microsoft could bring traditional object-oriented programs to the web. As it has developed, TypeScript's type system has evolved to model code written by native JavaScripters. The resulting system is powerful, interesting and messy.
This introduction is designed for working Haskell or ML programmers who want to learn TypeScript. It describes how the type system of TypeScript differs from Haskell's type system. It also describes unique features of TypeScript's type system that arise from its modelling of JavaScript code.
This introduction does not cover object-oriented programming. In practise, object-oriented programs in TypeScript are similar to those in other popular languages with OO features.
In this introduction, I assume you know the following:
If you need to learn the good parts of JavaScript, read JavaScript: The Good Parts. You may be able to skip the book if you know how to write programs in a call-by-value lexically scoped language with lots of mutability and not much else. R4RS Scheme is a good example.
The C++ Programming Language is a good place to learn about C-style type syntax. Unlike C++, TypeScript uses postfix types, like so: x: string
instead of string x
.
JavaScript defines 7 built-in types:
See the MDN page for more detail.
TypeScript has corresponding primitive types for the built-in types:
number