<p>TypeScript is a superset of ECMAScript and its compiler supports targetting ECMAScript 3; it even supports <code>yield</code> and <code>await</code> based on host environment's <code>Promise</code> and generator interfaces. ActionScript 3 is an ECMAScript 3 subset with only subtle differences such as <code>Boolean</code> and <code>Number</code> being auto-boxed types, e.g.:</p>
<pre class="lang-javascript prettyprint-override"><code>new Number(5) === 5 // true in AS3
new Number(5) === 5 // false in JS
</code></pre>
<p>Other things that come to mind are that class instance methods are bound:</p>
<pre><code>class C {
    function f():void {
        this // [object C]
    }
}
var o:C = new C
var f:Function = o.f
f()

var f2:Function = o.f
f === f2
</code></pre>
<p>The languages ActionScript 3 and Haxe are currently the only languages being used to develop Adobe AIR apps. I don't agree with Adobe AIR API at all, despite it still being alive and maintained by a Samsung company called HARMAN.</p>
<p>The TypeScript's main GitHub repository wiki has a short page on Compiler API, but it does not cover everything. I heard of some existing projects such as typescript-to-lua for the Roblox game, but I don't understand their codebase at all, besides some of the API this specific typescript-to-lua project uses is undefined for some reason and it doesn't seem to be the TypeScript NPM dependency version.</p>
<p>I already know how to output octet streams in general, but I still need to study control flow graph. Other than control flow graph (like translating <code>break</code> to jump instructions) and bytecode constant pool, what are the steps necessary to compile TypeScript to something like ActionScript 3 bytecode (aka. AVM2 bytecode)? How do I verify a program (i.e. parse and then resolve symbols and references), make sure there are no syntax or verification errors and transform it into AS3 bytecode?</p>

<compilers>
How could I use the TypeScript Compiler API to compile TypeScript to ActionScript 3 bytecode?
# How could I use the TypeScript Compiler API to compile TypeScript to ActionScript 3 bytecode?
Posted by: username_0 on 2023-05-30
TypeScript is a superset of ECMAScript and its compiler supports targetting ECMAScript 3; it even supports yield and await based on host environment's Promise and generator interfaces. ActionScript 3 is an ECMAScript 3 subset with only subtle differences such as Boolean and Number being auto-boxed types, e.g.:
new Number(5) === 5 // true in AS3
new Number(5) === 5 // false in JS

Other things that come to mind are that class instance methods are bound:
class C {
    function f():void {
        this // [object C]
    }
}
var o:C = new C
var f:Function = o.f
f()

var f2:Function = o.f
f === f2

The languages ActionScript 3 and Haxe are currently the only languages being used to develop Adobe AIR apps. I don't agree with Adobe AIR API at all, despite it still being alive and maintained by a Samsung company called HARMAN.
The TypeScript's main GitHub repository wiki has a short page on Compiler API, but it does not cover everything. I heard of some existing projects such as typescript-to-lua for the Roblox game, but I don't understand their codebase at all, besides some of the API this specific typescript-to-lua project uses is undefined for some reason and it doesn't seem to be the TypeScript NPM dependency version.
I already know how to output octet streams in general, but I still need to study control flow graph. Other than control flow graph (like translating break to jump instructions) and bytecode constant pool, what are the steps necessary to compile TypeScript to something like ActionScript 3 bytecode (aka. AVM2 bytecode)? How do I verify a program (i.e. parse and then resolve symbols and references), make sure there are no syntax or verification errors and transform it into AS3 bytecode?
**Tags:** compilers
---
## 0 answers
