-
Notifications
You must be signed in to change notification settings - Fork 245
/
index.ts
89 lines (80 loc) · 1.64 KB
/
index.ts
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/**
* Abstract class which represents a numeric value.
*/
export abstract class Value {
/**
* The value.
*/
abstract readonly value: number
/**
* String representation of the value.
*/
toString() {
return this.value.toString();
}
/**
* Returns the name of the class (to verify native type names are created for derived classes).
*/
typeName() {
return (this.constructor as any).name;
}
}
/**
* Represents a concrete number.
*/
export class Number extends Value {
/**
* Creates a Number object.
* @param value The number.
*/
constructor(readonly value: number) {
super();
}
/**
* The number multiplied by 2.
*/
get doubleValue() {
return 2 * this.value;
}
}
/**
* Represents an operation on values.
*/
export abstract class Operation extends Value {
abstract toString(): string
}
/**
* Applies to classes that are considered friendly. These classes can be greeted with
* a "hello" or "goodbye" blessing and they will respond back in a fun and friendly manner.
*/
export interface IFriendly {
/**
* Say hello!
*/
hello(): string
}
/**
* This is the first struct we have created in jsii
*/
export interface MyFirstStruct {
/**
* A string value
*/
astring: string
/**
* An awesome number value
*/
anumber: number
firstOptional?: string[]
}
/**
* This is a struct with only optional properties.
*/
export interface StructWithOnlyOptionals {
/**
* The first optional!
*/
optional1?: string
optional2?: number
optional3?: boolean
}