Note: The ability to both transpile and execute TypeScript code in the browser has since been added to the TypeScript Playground: https://www.typescriptlang.org/play
This repository is an experiment in transpiling TypeScript in the browser.
How does it work?
- The page loads
typescript.js
(typescript/lib/
) in some way (CDN,node_modules
) - The page has the
TypeScript
andts
objects available onwindow
- The TypeScript API can be used
- This demo transpiles TypeScript source text to JavaScript source text based on the demo in the TypeScript wiki
const { outputText, diagnostics, sourceMapText } = ts.transpileModule('const x: number = 5;', { compilerOptions: { target: 'esnext' } });
Remotely, see the online demo
Locally, run index.html
Investigate how loading typings could work