A tool that helps porting as3 codebase to typescript
This fork has major improvements parsing and emitting code. It has also a custom node visitor that allows extending the default behaviour.
Projects ported using
Option 1: via npm::
npm install -g as3-to-ts
Option 2: building the source:
Make sure you have Node v6+ installed.
- Clone the repository
You should have
as3-to-ts now globaly available in your commandline.
as3-to-ts <sourceDir> <outputDir> [--commonjs] [--visitors dictionary,stringutil,createjs] [--interactive] [--overwrite]
--commonjs: export .ts files using CommonJS's import style.
--visitors [name]: use custom visitors, separated by comma. implemented under
--overwrite: force overwrite of previously-converted files.
--interactive: if you've manually changed a generated
.tsfile, you'll be asked if you want to overwrite it or not.
supercalls on constructor need to be moved as the first call after conversion.
- having a comment on
extendsstatement causes infinite loop parsint the
breakwithout a semicolon results in infinite loop parsing the
- having a method without access level will throw
Error: invalid consume. (usually this is result of bad copy & paste without renaming the class constructor)
- having inline multiline comment break the parser (
var i = (/*comment*/true))
- namespaces can't have TypeScript keywords, such as
class, etc. (not an issue if transpiled using
- multiple property definitions generate invalid syntax (
public var velocityX:Number, velocityY:Number;)
However unlike most attempts that I have seen this tool is based on a true actionscript parser, and so should be able to handle most of as3 constructs and greatly ease the pain of porting a large code base written in as3 to typescript.