News for hackers. Stuff that matters.
Re:Announcing TypeScript 1.5 by Keats on Monday July 20, 2015 @01:37PM (#9917643)
Typescript definitely helped on all the projects I've used it.

The main con is that sometimes things are not very clear and you might end up spending time on something that typescript can't handle (eg a function that can return several types of objects, I had to put the return type of the function to any to have it compiled).

The pros:

- being able to refactor stuff easily with the compiler telling you

- catch typos easily (I remember watching Dan Abramov video at react europe and some of the errors he showed would be a compilation error in TS)

- if you maintain all your classes/object definitions in one file (except maybe stuff like state of a React component which doesn't need to be shared), you have all your types at one place and anyone can come in and have a clear view of the project: I had someone come help me on a previous project and it took him basically no time to get a grip on the project structure/models

- DefinitelyTyped so you can also type your calls to third party libraries and what they return

Make sure to only use ES6 imports (no internal modules) and it's pretty close to babel but with types.

Re:Announcing TypeScript 1.5 by Eridrus on Monday July 20, 2015 @03:22PM (#9918364)
> eg a function that can return several types of objects, I had to put the return type of the function to any to have it compiled

Typescript 1.4 to the rescue with union types!

Though I would argue that if this is code you're writing yourself, a function that returns multiple types is bad design. Though given the prevalence of different types for different strings, the way they've typed things like addEventListener is interesting.

Re:Announcing TypeScript 1.5 by Keats on Monday July 20, 2015 @03:50PM (#9918551)
It actually didn't work with 1.5 beta, can't remember the exact failure. This function actually returns an object depending on the single param, an enum member. All the objects are extending a main type with a couples different properties on each, it's cleaner than having a switch everywhere i want to instantiate one ofthose