forked from AssemblyScript/assemblyscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexports.ts
More file actions
60 lines (52 loc) · 1.19 KB
/
exports.ts
File metadata and controls
60 lines (52 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import "allocator/arena";
// top-level function
export function add(a: i32, b: i32): i32 {
return a + b;
}
export function subOpt(a: i32, b: i32 = 0): i32 {
return a - b;
}
// namespaced function
export namespace math {
export function sub(a: i32, b: i32): i32 {
return a - b;
}
}
// top-level enum
export const enum Animal {
CAT,
DOG
}
// namespaced enum
export namespace animals {
export const enum Animal {
CAT,
DOG
}
}
// top-level class
export class Car {
static readonly TIRES: i32 = 4;
static getNumTires(): i32 { return this.TIRES; }
constructor(public doors: i32 = 2) { this.doors = doors; }
get numDoors(): i32 { return this.doors; }
set numDoors(doors: i32) { this.doors = doors; }
openDoors(): void {}
}
// namespaced class
export namespace vehicles {
export class Car {
static readonly TIRES: i32 = 4;
static getNumTires(): i32 { return this.TIRES; }
constructor(public doors: i32 = 2) { this.doors = doors; }
get numDoors(): i32 { return this.doors; }
set numDoors(doors: i32) { this.doors = doors; }
openDoors(): void {}
}
}
// namespaced namespace
export namespace outer {
export namespace inner {
export const a = 42;
}
}