News for hackers. Stuff that matters.
Re:Announcing TypeScript 3.0 by polskibus on Monday July 30, 2018 @03:17PM (#17647148)
It would be great if there was a way to use the type information from within the code, ie. without type erasure.

Often we find that we create a nice model in TS, only to handle a lot of switching on types in the runtime. This is sometimes a smell but sometimes unavoidable, unless type information can be present in the runtime.

Re:Announcing TypeScript 3.0 by Stoids on Monday July 30, 2018 @04:16PM (#17647608)
That's probably unlikely to happen, as it falls out of line with the design goals of TS, but check out io-ts[0] for a library approach to this problem.

[0] https://github.com/gcanti/io-ts

Re:Announcing TypeScript 3.0 by ryanworl on Monday July 30, 2018 @05:11PM (#17648082)
Literally every release I check the notes, the roadmap, and the nearly 4 year old issue filed for runtime type information and every release I am disappointed.

All the TypeScript dependency injection libraries rely on decorators or something else requiring modifying the classes being injected.

It makes the code look terrible and this is really my only complaint about TypeScript which is otherwise fantastic. I basically only do DI by hand because of it.

Re:Announcing TypeScript 3.0 by steve_adams_86 on Monday July 30, 2018 @07:37PM (#17649238)
I use ajv's schema-based validation at all entry points to my application (user input from forms, urls, whatever comes back from an API, etc) and find I can very safely assume all data after that point is totally safe, so I'm using TypeScript to ensure _I'm_ not doing anything stupid. Hopefully that makes sense. Runtime type checking would be neat for sure, but I'm mostly worried about the dumb things I'll do. It's not too hard to strictly and cleanly validate foreign data at runtime, but it's historically very easy to shoot yourself in the foot with JavaScript. So I'm very happy.