TypeScript SPS Melb
TypeScript SPS Melb
• What is TypeScript
• Why do we need TypeScript
• How
• Demo
• Working with your existing JavaScript
What is TypeScript
• var x = 1; x = "hello";
// NOT OK, type is mixed up. We can't assume what type is x.
• var i = 1;
if (i == 1) {
var i = 2;
}
var y = function { var i = 3; }
Problem - object inheritance is hard
• var animal = {
var name;
};
• // js
function f(x, y) {
return x * y;
}
• // ts
function f(x : number, y : number) : number {
return x * y;
}
• #3 Optional arguments in
your functions