Export [v2.1-alpha.11+]

Marks a function, class or variable for wildcard import, and optionally marks it as the default export.

Export Default FunctionDefinition
Export Default ClassDefinition
Export Global Variables ; [v2.1-alpha.20+]

Parameters

FunctionDefinition

A full function definition.

[v2.1-alpha.22+]: For backward-compatibility, export cannot be used with a fat arrow function. For example, export fn() => 1 is interpreted as a call to a user-defined "export" function as in v2.0.

ClassDefinition

A class definition.

Variables

A list of global variable names and optional initializers, with the same rules as a global declaration.

Remarks

Functions, classes and variables can be explicitly imported or accessed through a reference to any module in which they are declared, but wildcard import only imports names which are explicitly exported.

Within each module, a single function or class export can be marked with the Default keyword to make it the module's default export. The name used in the declaration is not exported unless an additional export declaration is used. If there is no explicit default export, the module itself is the default export.

The use of an expression or variable as the default export is not implemented.

Only global names can be exported.

export can also be used in an #Import directive to simultaneously import names and export them from the current module.

[v2.1-alpha.20+]: For backward-compatibility, Export MyVar is interpreted as a function call statement. To export a variable, the Global keyword is required.

Modules, #Import, #Module, #Include

Examples

Simple examples.

export MyFunction() {
    return 42
}

export global MyVar, MyOtherVar := 1

export default class MyModule {
    ;...
}