idlize

Форк
0
320 строк · 8.8 Кб
1
/*
2
 * Copyright (c) 2024 Huawei Device Co., Ltd.
3
 * Licensed under the Apache License, Version 2.0 (the "License");
4
 * you may not use this file except in compliance with the License.
5
 * You may obtain a copy of the License at
6
 *
7
 *     http://www.apache.org/licenses/LICENSE-2.0
8
 *
9
 * Unless required by applicable law or agreed to in writing, software
10
 * distributed under the License is distributed on an "AS IS" BASIS,
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 * See the License for the specific language governing permissions and
13
 * limitations under the License.
14
 */
15

16
declare interface TestInterface { 
17
    (): TestAttribute
18
}
19

20
declare const Test: TestInterface
21

22
declare enum EnumDTS {
23
    ELEM_0 = 0,
24
    ELEM_1 = 1,
25
    ELEM_2 = 2,
26
}
27

28
declare interface BooleanInterfaceDTS {
29
    valBool: boolean
30
}
31

32
declare interface NumberInterfaceDTS {
33
    valNumber: number
34
}
35

36
declare interface StringInterfaceDTS {
37
    valString: string
38
}
39

40
declare interface UnionInterfaceDTS {
41

42
    unionProp: number | boolean
43
}
44

45
declare interface UnionOptionalInterfaceDTS {
46

47
    unionProp: string | undefined
48
}
49

50
declare interface TupleInterfaceDTS {
51

52
    tuple: [number, boolean]
53
}
54

55
declare interface TestTupleUnionInterfaceDTS {
56
    tuple: [number | boolean, number | StringInterfaceDTS]
57
}
58

59
declare interface OptionInterfaceDTS {
60

61
    tuple: [boolean?, number?]
62
}
63

64
declare interface OptionalTestInterface {
65
    optNumber?: number
66
    optString?: string
67
}
68

69
// declare interface ArrayRefNumberInterfaceDTS {
70

71
//     tuple: Array<number>
72
// }
73

74
// declare interface ArrayRefTuplesInterfaceDTS {
75

76
//     tuple: Array<[boolean, number]>
77
// }
78

79
// declare class ClassDTS {
80

81
//     valBoolean: boolean
82
// }
83

84
// // Non materialized class
85
// declare class ClassWithConstructorDTS {
86

87
//     constructor(valNumber: number, valString: string)
88
// }
89

90
// // Non materialized class
91
// declare class ClassWithConstructorAndFieldsDTS {
92

93
//     valNumber: number
94
//     valBoolean: boolean
95

96
//     constructor(valNumber: number, valBoolean: boolean)
97
// }
98

99
// // Materialized class
100
// declare class ClassWithConstructorAndMethodsDTS {
101

102
//     constructor(valNumber: number, valString: string)
103

104
//     method(valNumber: number, valString: string): void
105
// }
106

107
// // Materialized class
108
// declare class ClassWithConstructorAndStaticMethodsDTS {
109

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

112
//     static of(valNumber: number, valString: string): ClassWithConstructorAndStaticMethodsDTS
113
// }
114

115
// // Materialized class
116
// declare class ClassWithConstructorAndFieldsAndMethodsDTS {
117

118
//     valNumber: number
119
//     valBoolean: boolean
120

121
//     constructor(valNumber: number, valBoolean: boolean)
122

123
//     method(valNumber: number, valString: string): void
124
// }
125

126

127
// // Materialized class
128
// declare class ClassWithConstructorAndWithoutParamsDTS {
129

130
//     constructor()
131

132
//     static of(): ClassWithConstructorAndWithoutParamsDTS
133

134
//     method(): void
135
// }
136

137
// // Materialized class
138
// declare class ClassWithConstructorAndNonOptionalParamsDTS {
139

140
//     constructor(valNumber: number, valString: string)
141

142
//     static of(valNumber: number, valString: string): ClassWithConstructorAndNonOptionalParamsDTS
143

144
//     method(valBoolean: boolean, valString: string): void
145
// }
146

147
// // Materialized class
148
// declare class ClassWithConstructorAndSomeOptionalParamsDTS {
149

150
//     constructor(valNumber: number, valString?: string)
151

152
//     static of(valNumber: number, valString?: string): ClassWithConstructorAndSomeOptionalParamsDTS
153

154
//     method(valBoolean: boolean, valString?: string): void
155
// }
156

157
// // Materialized class
158
// declare class ClassWithConstructorAndAllOptionalParamsDTS {
159

160
//     constructor(valNumber?: number, valString?: string)
161

162
//     static of(valNumber?: number, valString?: string): ClassWithConstructorAndAllOptionalParamsDTS
163

164
//     method(valBoolean?: boolean, valString?: string): void
165
// }
166

167
// basic types:
168
// - boolean
169
// - number
170
// - string,
171
// - enum
172
// - function
173
//
174
// type | undefined    // undefined
175
// type1 | type2       // union
176
// type[]              // array
177
// [type1, type2]      // tuple
178
// [type1?, type2?]    // tuple optional
179
// [type1 | type2, (type3 | type 4)?]    // tuple union
180
// Array<type> // ArrayRef type
181
// Array<[type1, type2]> // ArrayRef tuple
182

183
declare class TestAttribute extends CommonMethod<TestAttribute> {
184

185
    // basic types
186
    testBoolean(value: boolean): TestAttribute;
187

188
    testNumber(value: number): TestAttribute;
189

190
    testString(value: string): TestAttribute;
191

192
    testEnum(value: EnumDTS): TestAttribute
193

194
    testFunction(value: (a: number) => boolean): TestAttribute;
195

196
    testBasicMix(v1: number, v2: string, v3: number): TestAttribute
197

198
    // undefined
199

200
    testBooleanUndefined(value: boolean | undefined): TestAttribute;
201

202
    testNumberUndefined(value: number | undefined): TestAttribute;
203

204
    testStringUndefined(value: string | undefined): TestAttribute;
205

206
    // testEnumUndefined(value: EnumDTS | undefined): TestAttribute;
207

208
    // testFunctionUndefined(value: (a: number) => boolean | undefined): TestAttribute;
209

210
    // union
211

212
    testUnionNumberEnum(val: number | EnumDTS): TestAttribute
213

214
    testUnionBooleanString(val: boolean | string): TestAttribute
215

216
    testUnionStringNumber(val: string | number): TestAttribute
217

218
    testUnionBooleanStringNumberUndefined(val: boolean | string | number | undefined): TestAttribute
219

220
    // // array
221

222
    // testBooleanArray(value: boolean[]): TestAttribute;
223

224
    // testNumberArray(value: number[]): TestAttribute;
225

226
    // testStringArray(value: string[]): TestAttribute;
227

228
    // testEnumArray(value: EnumDTS[]): TestAttribute
229

230
    // // TBD: array of functions
231
    // // testFunctionArray(value: ((a: number) => boolean)[]): TestAttribute;
232

233
    // testArrayMix(v1: number[], v2: string[], v3: EnumDTS[]): TestAttribute;
234

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

238
    // // tuple
239

240
    // testTupleBooleanNumber(value: [boolean, number]): TestAttribute;
241

242
    // testTupleNumberStringEnum(value: [number, string, EnumDTS]): TestAttribute;
243

244
    // // tuple optional
245

246
    // testTupleOptional(value: [number, string, boolean, EnumDTS]): TestAttribute;
247

248
    // // tuple union
249

250
    // testTupleUnion(value: [(number | string), (boolean | EnumDTS), (string | EnumDTS | boolean)]): TestAttribute;
251

252
    // // Array<Type>
253

254
    // testArrayRefBoolean(value: Array<boolean>): TestAttribute
255

256
    // testArrayRefNumber(value: Array<number>): TestAttribute
257

258
    // // testArrayTuple(value: Array<[number, boolean]>): TestAttribute
259

260
    // // interface
261

262
    testBooleanInterface(value: BooleanInterfaceDTS): TestAttribute
263

264
    testNumberInterface(value: NumberInterfaceDTS): TestAttribute
265

266
    testStringInterface(value: StringInterfaceDTS): TestAttribute
267

268
    testUnionInterface(value: UnionInterfaceDTS): TestAttribute
269

270
    testUnionOptional(value: UnionOptionalInterfaceDTS): TestAttribute
271

272
    testTupleInterface(value: TupleInterfaceDTS): TestAttribute
273

274
    testTupleInterface(value: TestTupleUnionInterfaceDTS): TestAttribute
275

276
    testOptionInterface(value: OptionInterfaceDTS): TestAttribute
277

278
    testOptionInterface(value: OptionalTestInterface): TestAttribute
279

280
    // testArrayRefNumberInterface(value: ArrayRefNumberInterfaceDTS): TestAttribute
281

282
    // // testArrayRefTupleInterface(value: ArrayRefTuplesInterfaceDTS)
283

284

285
    // // Boolean Interface
286

287
    // testBooleanInterfaceOption(value?: BooleanInterfaceDTS): TestAttribute
288

289
    // testBooleanInterfaceTuple(value: [BooleanInterfaceDTS]): TestAttribute
290

291
    // testBooleanInterfaceArray(value: BooleanInterfaceDTS[]): TestAttribute
292

293
    // testBooleanInterfaceArrayRef(value: Array<BooleanInterfaceDTS>): TestAttribute
294

295
    testInterfaceMixed(v1: UnionInterfaceDTS, v2: number, v3: TupleInterfaceDTS): TestAttribute
296

297
    // // Class
298

299
    // testClass(value: ClassDTS): TestAttribute
300

301
    // testClassWithConstructor(value: ClassWithConstructorDTS): TestAttribute
302

303
    // testClassWithConstructorAndFields(value: ClassWithConstructorAndFieldsDTS): TestAttribute
304

305
    // // Materialized class
306

307
    // testClassWithConstructorAndMethods(value: ClassWithConstructorAndMethodsDTS): TestAttribute
308

309
    // testClassWithConstructorAndStaticMethods(value: ClassWithConstructorAndStaticMethodsDTS): TestAttribute
310

311
    // testClassWithConstructorAndFieldsAndMethods(value: ClassWithConstructorAndFieldsAndMethodsDTS): TestAttribute
312

313
    // testClassWithConstructorAndNonOptionalParams(value: ClassWithConstructorAndNonOptionalParamsDTS): TestAttribute
314

315
    // testClassWithConstructorAndSomeOptionalParams(value: ClassWithConstructorAndSomeOptionalParamsDTS): TestAttribute
316

317
    // testClassWithConstructorAndAllOptionalParams(value: ClassWithConstructorAndAllOptionalParamsDTS): TestAttribute
318

319
    // testClassWithConstructorAndWithoutParams(value: ClassWithConstructorAndWithoutParamsDTS): TestAttribute
320
}
321

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

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

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

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