Hacker News new | ask | show | jobs
by ohnoesjmr 332 days ago
Is there a solution to get ts compiler embeddable into c++ project that uses v8, so it could compile the code on the fly?

Seems tsc itself requires node, but surely an api that takes a ts file as a string and returns a ts file as a string should be possible?

2 comments

tsc's code is mostly the type-checker, you want to look for a "transpiler" here, so embedding either swc, esbuild, sucrase or the like to handle the process of converting for you. I've never heard of one written in C++ but that may exist.
swc exists as wasm which any browser should be able to execute.
Perhaps you could use or build a C interface for swc, a TS compiler written in rust.
they could use swc-wasm-web as tsbro also uses swc-wasm-web
Hot damn