3 ms·
Another potential benefit - runtime metaprogramming. All types are erased when converted to JS, but I can imagine a lot of utility for runtime types in Typescr
by h0h0h0h0111 6y ago
Another potential benefit - runtime metaprogramming.
All types are erased when converted to JS, but I can imagine a lot of utility for runtime types in Typescript.
- williamdclt 6y agoObligated mention of runtypes (https://github.com/pelotom/runtypes https://github.com/pelotom/runtypes) that bridges the gap between type-land and runtime-land. It's not seamless at all but if you have a serious need for this sort of thing, it's great
- faichai 6y agoI think there is some experimental decorator syntax which will allow for extracting type info. Does runtypes interop with that? Or is planning to?
- phpnode 6y agothere's the reflect-metadata package but the type information it exposes is very limited, "object" instead of {a: "foo"} and so on.
- h0h0h0h0111 6y agoNot quite the same, but reminds me a bit of yup (https://github.com/jquense/yup https://github.com/jquense/yup)!