Very interesting post to me. There always was the argument that TS should be erasable and carry no runtime information, enums and decorators are a mistake, etc.<p>For what it's worth, I want my production bundle to be as small as possible. Most people use bundlers among TypeScript, which further complicates things.<p>I would love a <i>standard</i> library to e.g. generate type predicate functions from TS types.<p>Taming the beast from this end might even end up useful for things like compilers, no?<p>TS provides a nice mechanism to be strict in the frontend and validate types using runtime code, that is, type predicates.<p>But from a higher level, this has never been enough, and you want to map JSON to TS types using some kind of schema definition.<p>I would love to just be able to pass in a TypeScript type and generate its type predicate at compile time.<p>Unfortunately, this is impossible due to the halting problem.<p>So, a <i>standard</i> solution for the case of a plain serializable JS/JSON object and the according TS interface would be very much welcome.<p>Edit: and all of this is of course about data from external sources (requests, DOM, compiler...). For all of the code and data known at compile time, there is rarely a need to validate types, as they are statically analyzable.<p>So there is a huge scope that TypeScript has to cater to.
It includes JS projects where external type definitions often become obsolete and people who code in TS but do not enable strict mode for their own code (that is, disallow "any").
And all of these type defintions have to be interoperable.<p>For API requests, this is basically calling for a default generic REST client, and I agree that would be useful. The REST client could use type predicate functions extensively.