<!DOCTYPE html>
<html>
<head>
<title>TypeScript Compilation</title>
</head>
<body>
<div id="root"></div>
<textarea id="source" style="height: 300px; width: 500px;">
define(function (require) {
const b: any = require('some');
const c: any = 1;
if (1 == '2') {console.log(12);}
class A {
constructor (d) {
const a = 1;
}
}
class B extends A {
constructor () {
super();
}
render () {
return (
<div>a</div>;
);
}
}
// comments
});
</textarea>
<textarea id="result" style="height: 300px; width: 500px;"></textarea>
<script src="js/lib/typescript/typescriptServices.js"></script>
<script type="text/javascript">
var outputText = ts.transpileModule(document.getElementById('source').value, {
compilerOptions: {
module: 'none' // 'amd' or ts.ModuleKind.AMD
, target: 'es3' // ts.ScriptTarget.ES3
, noImplicitUseStrict: true
, noEmitHelpers: true
, removeComments: true
, sourceMap: true
, inlineSourceMap: true
, inlineSources: true
, jsx: 'react'
, importHelpers: true
}
, moduleName: ''
})
console.log(outputText);
outputText = outputText.outputText;
if (outputText === undefined) {throw new Error("Output generation failed");}
document.getElementById('result').innerHTML = outputText;
</script>
</body>
</html>
Комментариев нет:
Отправить комментарий