npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dts2as

v0.13.0

Published

A command line tool that converts TypeScript definitions (d.ts files) to ActionScript 3 classes and interfaces

Downloads

8

Readme

dts2as

A command line utility that converts TypeScript definitions (d.ts files) to ActionScript classes and interfaces and generates a SWC file. Use these SWCs with Apache FlexJS for strict compile-time type checking, as if the JavaScript library were written in ActionScript. You can add the SWCs to IDEs, like Visual Studio Code, Flash Builder, or IntelliJ IDEA, and you'll get helpful code suggestions as you type.

Installation

Requires Node.js.

npm install -g dts2as

Usage

dts2as hello.d.ts
dts2as file1.d.ts file2.d.ts
dts2as --outSWC hello.swc hello.d.ts
dts2as --outDir ./as3-files file.d.ts
dts2as --exclude com.example.SomeType file.d.ts

The following arguments are available:

  • -outSWC FILE

    Generate a compiled SWC file. Requires either FLEX_HOME environment variable or --flexHome option.

  • -outDir DIRECTORY

    Generate ActionScript files in a specific output directory. Defaults to ./dts2as_generated.

  • --flexHome DIRECTORY

    Specify the directory where Apache FlexJS is located. Defaults to FLEX_HOME environment variable, if available.

  • --moduleMetadata

    Adds [JSModule] metadata to CommonJS modules. If a module is used in code, Apache FlexJS will automatically require it.

  • -e SYMBOL or --exclude SYMBOL

    Specify the fully-qualified name of a symbol to exclude when emitting ActionScript.

  • -i SYMBOL or --include SYMBOL

    Specify the fully-qualified name of a symbol to include when emitting ActionScript. Excludes all other symbols.

  • -t VERSION or --target VERSION

    Specify ECMAScript target version for the TypeScript standard library: 'ES3', 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'Latest' (default)

  • -v or --version

    Print the version of dts2as.

Using the SWC with Apache FlexJS

To use the generated SWC file with Apache FlexJS, you need to append it to the external library path.

If you're using the FlexJS framework components, you can compile with mxmlc:

mxmlc --external-library-path+=generated.swc src/MyProject.mxml

For pure ActionScript projects that target native JavaScript APIs, like the HTML DOM, you can compile with asjsc:

asjsc --external-library-path+=generated.swc src/MyProject.as

For more details, please check out the following tutorial:

Introduction to dts2as: Using TypeScript definitions with ActionScript

Troubleshooting

TypeScript definition files support a surprisingly large subset of the TypeScript language. Sometimes, dts2as won't know how to parse some of the more advanced syntax (although it's certainly getting better at it over time!). When dts2as runs into problems, it may not be able to compile a SWC file for you. You have a few options when dts2as fails:

  • Use the --exclude option to remove some symbols that you know you won't need, or use the --include option to include only the symbols that you definitely need.

  • Modify the original d.ts file to simplify the TypeScript syntax or to remove some symbols that you don't need.

  • Use the --outDir option instead of the --outSWC option to generate only ActionScript files. Then, modify the ActionScript files and compile them into a SWC yourself.

Support this project

Want to see more ActionScript transpiler tools and utilities like dts2as? How about in-depth articles and step-by-step video tutorials that teach you how to use ActionScript with libraries like jQuery, CreateJS, and Pixi.js? Please become a patron and support the next generation of ActionScript development on the web -- without a plugin!

NextGen ActionScript by Josh Tynjala on Patreon

Special thanks to the following sponsors for their generous support: