Package net.jangaroo.jooc.config
Interface TypeScriptTargetSourceFormatFeature
-
public interface TypeScriptTargetSourceFormatFeature
-
-
Field Summary
Fields Modifier and Type Field Description static longSIMPLIFIED_AS_EXPRESSIONSSimplify(as(foo, Foo)).barto(foo as Foo).bar, i.e.static longSIMPLIFIED_THIS_USAGE_BEFORE_SUPER_CONSTRUCTOR_CALLSimplified syntax for Ext classes usingthisbeforesuper()constructor call.static longSTATIC_BLOCKSGenerate static blocks.
-
-
-
Field Detail
-
SIMPLIFIED_THIS_USAGE_BEFORE_SUPER_CONSTRUCTOR_CALL
static final long SIMPLIFIED_THIS_USAGE_BEFORE_SUPER_CONSTRUCTOR_CALL
Simplified syntax for Ext classes usingthisbeforesuper()constructor call. Instead of wrapping all code that does so inside an immediately-evaluating arrow function expression which nested inside thesupercall, an alias forthisis defined (namedthis$), and the alias assignment is forced to be accepted by the TypeScript compiler using// @ts-expect error.- See Also:
- Constant Field Values
-
SIMPLIFIED_AS_EXPRESSIONS
static final long SIMPLIFIED_AS_EXPRESSIONS
Simplify(as(foo, Foo)).barto(foo as Foo).bar, i.e. leave out runtime checks that, when failing, would have caused an NPE anyway. The ActionScriptasoperator returnsnullwhen the given expression is not of the given type. So when (immediately) de-referencing the result, the JavaScript equivalent of a NullPointerException would be raised. If the developer really wanted to raise an error when the type is not matched, they should have used a type cast instead, which would then throw aTypeError. This leads to the assumption that in this case,aswas meant as a compile-time type assertion only, which does not exist in ActionScript. However, TypeScript only supports compile-time type assertions, so to emulate ActionScript semantics, Jangaroo introduced a utility functionas(expr, type). The "simplified as-expressions" flag tells the Jangaroo compiler to convert immediately de-referencedas-expression to type assertions instead of calls to the Jangaroo utility functionas(). This saves runtime overhead and a value-dependency on the target type, which can help to resolve cyclic compilation unit dependencies (which are not allowed in ECMAScript). The only semantic difference is that when the expression is not of the given type, instead of an NPE, either the error is raised that the property that is then de-referenced does not exist, or, by coincidence, a property of the given name exists nevertheless, which may lead to consequential errors. If you want to switch on the flag in general, but prevent the conversion for certain code, simply extract the as-expression into a local variable or even better use a type cast instead.- See Also:
- Constant Field Values
-
STATIC_BLOCKS
static final long STATIC_BLOCKS
Generate static blocks. This ECMAScript feature is supported since TypeScript 4.4, but has a serious bug, namely that forward-references to static methods lead to a type error. This bug is fixed in TypeScript 4.7, so if your static code block ActionScript code contains forward references, you should only switch it on when targeting TypeScript 4.7+.- See Also:
- Constant Field Values
-
-