GoogleFeud / ts-runtime-checks

A typescript transformer that automatically generates validation code from your types.
https://googlefeud.github.io/ts-runtime-checks/
MIT License
312 stars 7 forks source link

Supported as NextJS / SWC plugin? #12

Closed mfigurski80 closed 1 year ago

mfigurski80 commented 1 year ago

As the title implies, I'd love to use this library inside my NextJS project, which uses SWC for compilation, but have not found an easy way to include it in either frameworks' plugin system -- might be somewhat hard to integrate with. It'd be nice to have this tool natively support (or have an adapter of some sort) so they can be included in an SWC compilation pipeline, or have an issue like this one that focuses on documenting the integration with common frameworks.

Feel like supporting this could precipitate a lot of new interest in the repository. Obviously, if this requires a total rewrite, that might be prohibitive, but if you see a path forward I'd love to help make something like this possible.

GoogleFeud commented 1 year ago

Hello! This transformer uses typescript's type checker to detect the usage of the Assert and EarlyReturn types, and more importantly get type information and what needs to be checked. Since SWC just transpiles typescript without type-checking it, this kind of plugin is impossible to create for SWC.