AssemblyScript compiles TypeScript to WebAssembly

Posted on 11-09-2017 , by: admin , in , 0 Comments

A project called AssemblyScript is providing a bridge between WebAssembly, the portable binary code format designed to make web applications run faster, and TypeScript, Microsoft’s typed JavaScript superset. 

A subset of TypeScript itself, AssemblyScript gives developers with a background in TypeScript and standard JavaScript APIs a way to compile to WebAssembly. The project is currently characterized as being in a beta state of development by its main developer, Daniel Wirtz. “My aim [with AssemblyScript] is to create something simple, i.e. something you can ‘npm install’ to compile to WebAssembly instead of installing and setting up more complex tool chains,” he said.

What AssemblyScript does is rewire the TypeScript compiler API to the BInaryen compiler back end, which is is able to produce WebAssembly binaries. Rather than re-implementing TypeScript as closely as possible at the expense of performance, AssemblyScript attempts to support features as closely as is reasonable without supporting certain dynamic constructs. AssemblyScript programs are valid TypeScript syntactically although not necessarily semantically. 

AssemblyScript has a few special requirements. For example, types must be annotated to avoid unwanted implicit conversions. Also, optional functional parameters require an initializer expression. Union types, except classType | null, any, and undefined are not supported by design.