These are all things that many people complain that JavaScript does not have built in. With TypeScript, JavaScript does not magically gain these things. TypeScript makes these things accessible to a developer through its pre processing. Developers and JavaScript do not need TypeScript, and it is not a requirement to build large scale applications. It won't magically make crappy programming better, but it may help catch a gotcha for someone every now and again, just as JSHint would. I for one think that it will take off rather well, especially in the ASP.Net community. I also will probably try it out in a project or two or three. I like that it looks and feels like JavaScript, which is a syntax that I am comfortable with. That is one reason why I have not adopted CoffeeScript, it just looks so foreign to me. I suppose if I were a full time Ruby on Rails developer, CoffeeScript would feel right, but I'm not, so it doesn't.
I'm going to end this by just showing the difference between TypeScript and JavaScript. It is subtle and that is appealing to me. See the comparisons below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Greeter { | |
greeting: string; | |
constructor (message: string) { | |
this.greeting = message; | |
} | |
greet() { | |
return "Hello, " + this.greeting; | |
} | |
} | |
var greeter = new Greeter("world"); | |
var button = document.createElement('button') | |
button.innerText = "Say Hello" | |
button.onclick = function() { | |
alert(greeter.greet()) | |
} | |
document.body.appendChild(button) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Greeter = (function () { | |
function Greeter(message) { | |
this.greeting = message; | |
} | |
Greeter.prototype.greet = function () { | |
return "Hello, " + this.greeting; | |
}; | |
return Greeter; | |
})(); | |
var greeter = new Greeter("world"); | |
var button = document.createElement('button'); | |
button.innerText = "Say Hello"; | |
button.onclick = function () { | |
alert(greeter.greet()); | |
}; | |
document.body.appendChild(button); |