Studio Developer Manual / Version 2301
Table Of ContentsIn Ext JS, each compilation unit contains exactly one declaration that is visible from the outside, usually a class. In TypeScript modules, it is possible to export multiple identifiers, but there is a default export. So when converting code to Ext JS, it is straight-forward to use this default export to export the primary declaration of the compilation unit.
While it is possible to combine the declaration and the (default) export of a class, the code style in the Blueprint workspace is to separate them, because later you'll see cases where TypeScript's declaration merging is used, which would lead to redundant export directives. So the recommended code style is to always end each source file with the default export, like in this example class:
import { is, mixin } from "@jangaroo/runtime"; import SuperFoo from "./SuperFoo"; import IFoo from "../api/IFoo"; class Foo extends SuperFoo implements IFoo { static readonly FOO: any = "FOO"; foo: string; #bar: number; constructor(newBar: number) { super(); this.#bar = newBar; } get bar(): number { return this.#bar; } set bar(value: number) { this.#bar = value; } isAFoo(obj: any): boolean { return is(obj, IFoo); } protected hook(): boolean { return false; } } mixin(Foo, IFoo); default export Foo;
Example 5.4. Using the default export for Ext TS classes