6

I'd like to run the TypeScript compiler within a website in order to build something like the playground on TypeScript's website TypeScript Playground.

In opposite of running tsc on the server side, I'd like to run compile it directly within JS. I've looked for any similar posts here and any description within the TypeScript language specification, but I can't find any information on that.

sepp2k
  • 363,768
  • 54
  • 674
  • 675
Thorsten Hans
  • 2,675
  • 19
  • 21
  • 1
    possible duplicate of [TypeScript Web-Based IDE](http://stackoverflow.com/questions/14283737/typescript-web-based-ide) - hopefully that will answer your question. – Fenton Jan 29 '13 at 17:06

3 Answers3

2

The typescript compiler is written in Typescript, so you can load the compiler (typescript.js) into your browser. But bare in mind that it is slightly heavy (roughly 250 KB).

ppoliani
  • 4,792
  • 3
  • 34
  • 62
2

There's some documentation on the TS Compiler API and there's also typestring - a wrapper that is still intended for use in NodeJS, but you can use it as a starting point.

Boycott Russia
  • 11,818
  • 5
  • 28
  • 29
2

Yes, it's possible to use TypeScript compiler in the browser without any hack. Checkout my examples playground and monaco-editor demos in this answer: TypeScript Web-Based IDE

cancerbero
  • 6,799
  • 1
  • 32
  • 24