Re:Convert React JavaScript Code to TypeScript with Proper T...
by joe-stanton on Tuesday January 16, 2018 @02:29PM
(#16161426)
You might be interested in this: https://github.com/gcanti/io-ts and many related projects by Giulio.
Re:Convert React JavaScript Code to TypeScript with Proper T...
by joe-stanton on Tuesday January 16, 2018 @02:32PM
(#16161459)
Beforehand I built something very similar to what you described for Flow (https://hackernoon.com/runtime-introspection-of-flow-types-d...).
Many others superseded this implementation, the above being one example.
Re:Convert React JavaScript Code to TypeScript with Proper T...
by tehno on Tuesday January 16, 2018 @03:13PM
(#16161933)
There's also very similar project at https://github.com/pelotom/runtypes that our company uses. Don't have enough experience with it yet to say which is better, io-ts on runtypes.
Re:Convert React JavaScript Code to TypeScript with Proper T...
by dvdsgl on Tuesday January 16, 2018 @02:29PM
(#16161424)
quicktype (https://app.quicktype.io/) can generate TypeScript types from JSON, Schema, and GraphQL, and it also emits a runtime type representation to do dynamic typechecking. Perhaps this isn't exactly what you're looking for but you could easily modify it to generate whatever code you'd like. We have an experimental Handlebar-based templating feature to make customizing the generated code easier.
I use typescript quite a bit and am starting to hit some patterns that could be abstracted nicely if metaprogramming tools were in the shed.