Interface TypeScriptTargetSourceFormatFeature


  • public interface TypeScriptTargetSourceFormatFeature
    • Field Detail

      • SIMPLIFIED_THIS_USAGE_BEFORE_SUPER_CONSTRUCTOR_CALL

        static final long SIMPLIFIED_THIS_USAGE_BEFORE_SUPER_CONSTRUCTOR_CALL
        Simplified syntax for Ext classes using this before super() constructor call. Instead of wrapping all code that does so inside an immediately-evaluating arrow function expression which nested inside the super call, an alias for this is defined (named this$), 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)).bar to (foo as Foo).bar, i.e. leave out runtime checks that, when failing, would have caused an NPE anyway. The ActionScript as operator returns null when 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 a TypeError. This leads to the assumption that in this case, as was 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 function as(expr, type). The "simplified as-expressions" flag tells the Jangaroo compiler to convert immediately de-referenced as-expression to type assertions instead of calls to the Jangaroo utility function as(). 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