Recs.
Updated
TypeScript is a language for application-scale JavaScript development.
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
SpecsUpdate
Pros
Pro Learn JavaScript and types at the same time
JavaScript is the language of the web and has a syntax similar to a lot of other languages but doesn't teach types, which is a concept fundamental to understanding the nature of computer code. Learning TypeScript now may involve a very slightly steeper learning curve than vanilla JavaScript but will be well worth it in the long run.
Pro It feels a lot like the C# of the web, to save the messiness of javascript
Especially in large projects, the stronger type system is a definite win over javascript, because javascript gets to be a mess quickly with many programmers in a team... while still keeping the power of javascript.
Pro Somewhat future-proof browser code
The TS team targets the newest browser standards and helps you backfill in existing browsers, all with one simple tool (instead of babel+flow+???). Far better options for the server side though, but given that coding for the browser is the new qbasic, this is a good place to start.
Cons
Con Far less typed libraries than Dart (and TSD are never up to date).
Just compare https://pub.dartlang.org/packages and http://definitelytyped.org/tsd/
Typescript => 930
Dart => 2060
Con Awful error messages
Comparing to Elm or Rust for example, TypeScript's error messages won't say you very much. For example if you change method of interface which your class implements it won't say your class have incorrect implementation. Instead it'll show error in usage of instances of class. In some cases it can spoil hours of your work trying to figure out why your parameters are incorrect.
Con Limiting to the JS target system (browsers)
As TS get compiled into JS its usage is limited to the browser's code. Which is not good for the first language to learn.
Con Will be replaced soon (hopefully)
There are many attempts to replace JS with something better. Current wave is WebAssembly. If not it something else will replace JS sooner rather then later.
Con Is not designed for big systems
As any scripting languages JS is difficult to maintain big system with many independently developed libraries.
Con Type inference coverage is incomplete
The default type when declaring and using a variable is any
. For example, the following should break but does not:
function add(a:number) { return a + 1 }
function addAB(a, b) {return add(a) + b}
addAB("this should break but doesn't :(", 100)
In order to avoid this, you have to declare type signatures for every variable or parameter or set the flag --noImplicityAny
when running the compiler.