apache / apache/royale-asjs

(Question) Ability to write typedef classes?

Open
#385 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
ActionScript
Stars
380
Forks
120
PR merge metrics
No merged PRs in 30d

Description

Hello!

Sorry to write a question here as an issue, but is there a way using meta-data (like the @externs metadata) to have a typedef class in Royale?

We have the `openfl.*` package defined in OpenFL, but we also want code referencing `flash.*` classes to work as well. We can do separate trees in our SWC externs (and do currently), but this results in a compiler error when it says that `openfl.display.Sprite` cannot be converted to unrelated type `flash.display.Sprite`... we want them to be the same. I tried something like the following, but it did not compile properly because it said there was no runtime constant of the class:

```as3
package flash.display {
import openfl.display.Sprite;
public const Sprite:Class = openfl.display.Sprite;
}
```

Is there another way? Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the @externs metadata example, the ActionScript typedef snippet, and the separate SWC extern trees described in the issue. Reproduce the compiler error about openfl.display.Sprite and flash.display.Sprite, then trace how the compiler handles those externs and runtime constants. Done means establishing whether typedef classes are supported and documenting the required approach or limitation.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.