News for hackers. Stuff that matters.
Re:Announcing TypeScript 2.1 by daxfohl on Wednesday December 07, 2016 @02:05PM (#13125196)
I assume you mean lookup types rather than mapped types; the latter has nothing to do with strings.

In general, in application-facing code I think you're absolutely correct: using strings as lookups is a hack that should be discouraged. (Though sometimes it's convenient when dealing with other JS libraries).

However the feature brings some strong metaprogramming abilities that wouldn't be possible otherwise. For instance I'd have to imagine that mapped types were implemented by using those features, and the ability to define types as variants of other types (beyond ordinary generics) is something very powerful.

I'm primarily an F# user and have been begging for something like this there. The ability to define variations on record types (without and id/timestamp for inserts, with those fields otherwise; hashed/raw password fields for your various user records; etc) in a typesafe manner without a ton of repetition is a game changer.

There are no comments on this comment yet.