4 ms·
This is insane! Just curios, are there real-world use cases for stuff like this?
by soheilpro 6y ago
This is insane!
Just curios, are there real-world use cases for stuff like this?
- williamdclt 6y agoI could imagine working on very complex static JSON. You want to type-check selections and transformations on this JSON. It's a very niche use-case, this is definitely more of an impressive showcase of the new Template Literal Types feature of TS :)
- ricksharp 6y agoYou can import a json document directly into typescript and the entire document is a readonly constant type of the entire json object literal. I've used this with a template JSON document that has an instance of all possible types in the runtime json. Sometimes you might have to loosen the type slightly, but it works great for a quick start.
- greencore 6y agoYou can embed any language interpreter into TypeScript and have that language syntaticaly checked by TS compiler.