Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Common Issues with dts2as

Josh Tynjala edited this page May 26, 2016 · 5 revisions

Error: Could not create SWC file. The generated ActionScript contains compile-time errors.

This error usually indicates that dts2as has encountered some TypeScript syntax that it does not recognize. Please report a bug on Github. Be sure to include a link to download the d.ts file that you passed to dts2as, along with the command line arguments that you specified.

As a workaround, if you are familiar with TypeScript, you may try modifying the d.ts file to use slightly different syntax. TypeScript is very flexible, and there is often more than one way to expose a JavaScript API. The generated ActionScript usually changes when you use different TypeScript syntax, so it might be possible to bypass the error.

You might also try using the --exclude argument to omit a specific type, if it isn't a dependency of anything else:

dts2as --exclude com.example.SomeClass --outSWC out.swc file.d.ts

Some member variables or methods are missing from the generated ActionScript.

Certain names cannot be used as members of classes or interfaces in ActionScript. When these are encountered by dts2as they will be skipped. For example, you may not use public, private, protected, or internal as member names:

public var private:String; //error!

Similarly, you cannot start a member name with a number:

public var 400:String; //error!

To access these properties in ActionScript, use brackets for dynamic access, like this:

var value1:Object = object["private"];
var value2:Object = object["400"];