How to run the TypeScript compiler on a website

I would like to run the TypeScript compiler on a website to build something like a playground on the TypeScript site TypeScript Playground .

Unlike running tsc on the server side, I would like to run the compilation directly in JS. I've searched for any similar posts here and any description in the TypeScript language spec, but I can't find any information on that.

+3


source to share


2 answers


The typescript compiler is written in Typescript, so you can load the compiler (typescript.js) into your browser. But don't forget that it is a little heavy (about 250KB).



+2


source


There is documentation for the TS Compiler API and typestring is a wrapper that is still meant to be used in NodeJS, but you can use that as a starting point.



0


source







All Articles