idlize

Форк
0
/
test.d.ts 
290 строк · 7.5 Кб
1
declare enum EnumDTS {
2
    ELEM_0 = 0,
3
    ELEM_1 = 1,
4
    ELEM_2 = 2,
5
}
6

7
declare interface BooleanInterfaceDTS {
8
    valBool: boolean
9
}
10

11
declare interface NumberInterfaceDTS {
12
    valNumber: number
13
}
14

15
declare interface StringInterfaceDTS {
16
    valString: string
17
}
18

19
declare interface UnionInterfaceDTS {
20

21
    unionProp: number | boolean
22
}
23

24
declare interface UnionOptionalInterfaceDTS {
25

26
    unionProp: string | undefined
27
}
28

29
declare interface TupleInterfaceDTS {
30

31
    tuple: [number, boolean]
32
}
33

34
declare interface OptionInterfaceDTS {
35

36
    tuple: [boolean?, number?]
37
}
38

39
declare interface ArrayRefNumberInterfaceDTS {
40

41
    tuple: Array<number>
42
}
43

44
declare interface ArrayRefTuplesInterfaceDTS {
45

46
    tuple: Array<[boolean, number]>
47
}
48

49
declare class ClassDTS {
50

51
    valBoolean: boolean
52
}
53

54
// Non materialized class
55
declare class ClassWithConstructorDTS {
56

57
    constructor(valNumber: number, valString: string)
58
}
59

60
// Non materialized class
61
declare class ClassWithConstructorAndFieldsDTS {
62

63
    valNumber: number
64
    valBoolean: boolean
65

66
    constructor(valNumber: number, valBoolean: boolean)
67
}
68

69
// Materialized class
70
declare class ClassWithConstructorAndMethodsDTS {
71

72
    constructor(valNumber: number, valString: string)
73

74
    method(valNumber: number, valString: string): void
75
}
76

77
// Materialized class
78
declare class ClassWithConstructorAndStaticMethodsDTS {
79

80
    constructor(valNumber: number, valString: string)
81

82
    static of(valNumber: number, valString: string): ClassWithConstructorAndStaticMethodsDTS
83
}
84

85
// Materialized class
86
declare class ClassWithConstructorAndFieldsAndMethodsDTS {
87

88
    valNumber: number
89
    valBoolean: boolean
90

91
    constructor(valNumber: number, valBoolean: boolean)
92

93
    method(valNumber: number, valString: string): void
94
}
95

96

97
// Materialized class
98
declare class ClassWithConstructorAndWithoutParamsDTS {
99

100
    constructor()
101

102
    static of(): ClassWithConstructorAndWithoutParamsDTS
103

104
    method(): void
105
}
106

107
// Materialized class
108
declare class ClassWithConstructorAndNonOptionalParamsDTS {
109

110
    constructor(valNumber: number, valString: string)
111

112
    static of(valNumber: number, valString: string): ClassWithConstructorAndNonOptionalParamsDTS
113

114
    method(valBoolean: boolean, valString: string): void
115
}
116

117
// Materialized class
118
declare class ClassWithConstructorAndSomeOptionalParamsDTS {
119

120
    constructor(valNumber: number, valString?: string)
121

122
    static of(valNumber: number, valString?: string): ClassWithConstructorAndSomeOptionalParamsDTS
123

124
    method(valBoolean: boolean, valString?: string): void
125
}
126

127
// Materialized class
128
declare class ClassWithConstructorAndAllOptionalParamsDTS {
129

130
    constructor(valNumber?: number, valString?: string)
131

132
    static of(valNumber?: number, valString?: string): ClassWithConstructorAndAllOptionalParamsDTS
133

134
    method(valBoolean?: boolean, valString?: string): void
135
}
136

137
declare interface TestInterface { 
138
    (): TestAttribute
139
}
140
declare const Test: TestInterface
141

142
// basic types:
143
// - boolean
144
// - number
145
// - string,
146
// - enum
147
// - function
148
//
149
// type | undefined    // undefined
150
// type1 | type2       // union
151
// type[]              // array
152
// [type1, type2]      // tuple
153
// [type1?, type2?]    // tuple optional
154
// [type1 | type2, (type3 | type 4)?]    // tuple union
155
// Array<type> // ArrayRef type
156
// Array<[type1, type2]> // ArrayRef tuple
157
declare class TestAttribute extends CommonMethod<TestAttribute> {
158

159
    // basic types
160
    testBoolean(value: boolean): TestAttribute;
161

162
    testNumber(value: number): TestAttribute;
163

164
    testString(value: string): TestAttribute;
165

166
    testEnum(value: EnumDTS): TestAttribute
167

168
    testFunction(value: (a: number) => boolean): TestAttribute;
169

170
    testBasicMix(v1: number, v2: string, v3: number): TestAttribute
171

172
    // undefined
173

174
    testBooleanUndefined(value: boolean | undefined): TestAttribute;
175

176
    testNumberUndefined(value: number | undefined): TestAttribute;
177

178
    testStringUndefined(value: string | undefined): TestAttribute;
179

180
    testEnumUndefined(value: EnumDTS | undefined): TestAttribute;
181

182
    testFunctionUndefined(value: (a: number) => boolean | undefined): TestAttribute;
183

184
    // union
185

186
    testUnionNumberEnum(val: number | EnumDTS): TestAttribute
187

188
    testUnionBooleanString(val: boolean | string): TestAttribute
189

190
    testUnionStringNumber(val: string | number): TestAttribute
191

192
    testUnionBooleanStringNumberUndefined(val: boolean | string | number | undefined): TestAttribute
193

194
    // array
195

196
    testBooleanArray(value: boolean[]): TestAttribute;
197

198
    testNumberArray(value: number[]): TestAttribute;
199

200
    testStringArray(value: string[]): TestAttribute;
201

202
    testEnumArray(value: EnumDTS[]): TestAttribute
203

204
    // TBD: array of functions
205
    // testFunctionArray(value: ((a: number) => boolean)[]): TestAttribute;
206

207
    testArrayMix(v1: number[], v2: string[], v3: EnumDTS[]): TestAttribute;
208

209
    // TBD: array of functions
210
    //testArrayMix(v1: number[], v2: string[], v3: EnumDTS[], v4: ((a: number) => string)[]): TestAttribute;
211

212
    // tuple
213

214
    testTupleBooleanNumber(value: [boolean, number]): TestAttribute;
215

216
    testTupleNumberStringEnum(value: [number, string, EnumDTS]): TestAttribute;
217

218
    // tuple optional
219

220
    testTupleOptional(value: [number, string, boolean, EnumDTS]): TestAttribute;
221

222
    // tuple union
223

224
    testTupleUnion(value: [(number | string), (boolean | EnumDTS), (string | EnumDTS | boolean)]): TestAttribute;
225

226
    // Array<Type>
227

228
    testArrayRefBoolean(value: Array<boolean>): TestAttribute
229

230
    testArrayRefNumber(value: Array<number>): TestAttribute
231

232
    // testArrayTuple(value: Array<[number, boolean]>): TestAttribute
233

234
    // interface
235

236
    testBooleanInterface(value: BooleanInterfaceDTS): TestAttribute
237

238
    testNumberInterface(value: NumberInterfaceDTS): TestAttribute
239

240
    testStringInterface(value: StringInterfaceDTS): TestAttribute
241

242
    testUnionInterface(value: UnionInterfaceDTS): TestAttribute
243

244
    testUnionOptional(value: UnionOptionalInterfaceDTS): TestAttribute
245

246
    testTupleInterface(value: TupleInterfaceDTS): TestAttribute
247

248
    testOptionInterface(value: OptionInterfaceDTS): TestAttribute
249

250
    testArrayRefNumberInterface(value: ArrayRefNumberInterfaceDTS): TestAttribute
251

252
    // testArrayRefTupleInterface(value: ArrayRefTuplesInterfaceDTS)
253

254

255
    // Boolean Interface
256

257
    testBooleanInterfaceOption(value?: BooleanInterfaceDTS): TestAttribute
258

259
    testBooleanInterfaceTuple(value: [BooleanInterfaceDTS]): TestAttribute
260

261
    testBooleanInterfaceArray(value: BooleanInterfaceDTS[]): TestAttribute
262

263
    testBooleanInterfaceArrayRef(value: Array<BooleanInterfaceDTS>): TestAttribute
264

265
    testInterfaceMixed(v1: UnionInterfaceDTS, v2: number, v3: TupleInterfaceDTS): TestAttribute
266

267
    // Class
268

269
    testClass(value: ClassDTS): TestAttribute
270

271
    testClassWithConstructor(value: ClassWithConstructorDTS): TestAttribute
272

273
    testClassWithConstructorAndFields(value: ClassWithConstructorAndFieldsDTS): TestAttribute
274

275
    // Materialized class
276

277
    testClassWithConstructorAndMethods(value: ClassWithConstructorAndMethodsDTS): TestAttribute
278

279
    testClassWithConstructorAndStaticMethods(value: ClassWithConstructorAndStaticMethodsDTS): TestAttribute
280

281
    testClassWithConstructorAndFieldsAndMethods(value: ClassWithConstructorAndFieldsAndMethodsDTS): TestAttribute
282

283
    testClassWithConstructorAndNonOptionalParams(value: ClassWithConstructorAndNonOptionalParamsDTS): TestAttribute
284

285
    testClassWithConstructorAndSomeOptionalParams(value: ClassWithConstructorAndSomeOptionalParamsDTS): TestAttribute
286

287
    testClassWithConstructorAndAllOptionalParams(value: ClassWithConstructorAndAllOptionalParamsDTS): TestAttribute
288

289
    testClassWithConstructorAndWithoutParams(value: ClassWithConstructorAndWithoutParamsDTS): TestAttribute
290
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.