News for hackers. Stuff that matters.
Re:I Was Wrong About TypeScript by shuzchen on Sunday June 05, 2016 @04:39PM (#11843002)
I was just about to complain how TS fails totally for typechecking backbone models or immutablejs datastructures: both situations where obj.get("foo") and obj.get("bar") return a particular type but there's no way of having TS handle that except defining them as any. But it turns out string literal types in 1.8 will make that work. And this was out since February! I should reevaluate TS for my omniscient project.
Re:I Was Wrong About TypeScript by danielearwicker on Sunday June 05, 2016 @11:57PM (#11844553)
The example you give has been supported since day 1. Example: document.createElement("canvas") returns HTMLCanvasElement. A limited form of string literal types has always been supported specifically for overloading return types. The newer support added in 1.8 is a way more powerful generalisation.
Re:I Was Wrong About TypeScript by rubber_duck on Sunday June 05, 2016 @06:43PM (#11843541)
IIRC there is no ergonomic way to define typed records for Immutable.js ?
Re:I Was Wrong About TypeScript by girvo on Sunday June 05, 2016 @08:20PM (#11843883)
If I recall correctly, you still can't type Immutable.js nicely with Flow, let alone Typescript, so I'm not surprised tbh
Re:I Was Wrong About TypeScript by danielearwicker on Sunday June 05, 2016 @11:54PM (#11844544)
Re:I Was Wrong About TypeScript by nidu on Monday June 06, 2016 @02:12AM (#11844957)
It could also benefit from constant propagation (iirc the term) where you could write obj.get(Item.name) and both get type check and stay refactoring friendly (though with cost of some more typing).