Transpile Typescript online
Using https://klesun-misc.github.io/TypeScript/lib/typescriptServices.js (
Source
)
(tslib.js required: https://github.com/microsoft/tslib)
Input (Javascript):
const mytext : string = "Test"; const myfunc = (text:string) : string => `${text} ${text}`; window.alert( myfunc(mytext) ); class MyClass { //field name:string; //constructor constructor(name:string) { this.name = name } //function /** * @method show * @return {void} */ show():void { console.log("MyClass.name is : "+this.name) } } // Array destruction with the spread operator const arr1 : Array
= [ 3,4,5 ]; const arr2: Array
= [ ...arr1 ]; console.log( arr2 ); // Map const arr3 = arr1.map((elem,index) => Math.pow(elem,2)); console.log(arr3); // Reduce const sum = arr3.reduce((sum,elem) => sum+elem,0); console.log(sum);
Transpile
Output (Typescript):
Execute JS