idlize
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
16declare interface TestInterface {17(): TestAttribute18}
19
20declare const Test: TestInterface21
22declare enum EnumDTS {23ELEM_0 = 0,24ELEM_1 = 1,25ELEM_2 = 2,26}
27
28declare interface BooleanInterfaceDTS {29valBool: boolean30}
31
32declare interface NumberInterfaceDTS {33valNumber: number34}
35
36declare interface StringInterfaceDTS {37valString: string38}
39
40declare interface UnionInterfaceDTS {41
42unionProp: number | boolean43}
44
45declare interface UnionOptionalInterfaceDTS {46
47unionProp: string | undefined48}
49
50declare interface TupleInterfaceDTS {51
52tuple: [number, boolean]53}
54
55declare interface TestTupleUnionInterfaceDTS {56tuple: [number | boolean, number | StringInterfaceDTS]57}
58
59declare interface OptionInterfaceDTS {60
61tuple: [boolean?, number?]62}
63
64declare interface OptionalTestInterface {65optNumber?: number66optString?: string67}
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
183declare class TestAttribute extends CommonMethod<TestAttribute> {184
185// basic types186testBoolean(value: boolean): TestAttribute;187
188testNumber(value: number): TestAttribute;189
190testString(value: string): TestAttribute;191
192testEnum(value: EnumDTS): TestAttribute193
194testFunction(value: (a: number) => boolean): TestAttribute;195
196testBasicMix(v1: number, v2: string, v3: number): TestAttribute197
198// undefined199
200testBooleanUndefined(value: boolean | undefined): TestAttribute;201
202testNumberUndefined(value: number | undefined): TestAttribute;203
204testStringUndefined(value: string | undefined): TestAttribute;205
206// testEnumUndefined(value: EnumDTS | undefined): TestAttribute;207
208// testFunctionUndefined(value: (a: number) => boolean | undefined): TestAttribute;209
210// union211
212testUnionNumberEnum(val: number | EnumDTS): TestAttribute213
214testUnionBooleanString(val: boolean | string): TestAttribute215
216testUnionStringNumber(val: string | number): TestAttribute217
218testUnionBooleanStringNumberUndefined(val: boolean | string | number | undefined): TestAttribute219
220// // array221
222// testBooleanArray(value: boolean[]): TestAttribute;223
224// testNumberArray(value: number[]): TestAttribute;225
226// testStringArray(value: string[]): TestAttribute;227
228// testEnumArray(value: EnumDTS[]): TestAttribute229
230// // TBD: array of functions231// // testFunctionArray(value: ((a: number) => boolean)[]): TestAttribute;232
233// testArrayMix(v1: number[], v2: string[], v3: EnumDTS[]): TestAttribute;234
235// // TBD: array of functions236// //testArrayMix(v1: number[], v2: string[], v3: EnumDTS[], v4: ((a: number) => string)[]): TestAttribute;237
238// // tuple239
240// testTupleBooleanNumber(value: [boolean, number]): TestAttribute;241
242// testTupleNumberStringEnum(value: [number, string, EnumDTS]): TestAttribute;243
244// // tuple optional245
246// testTupleOptional(value: [number, string, boolean, EnumDTS]): TestAttribute;247
248// // tuple union249
250// testTupleUnion(value: [(number | string), (boolean | EnumDTS), (string | EnumDTS | boolean)]): TestAttribute;251
252// // Array<Type>253
254// testArrayRefBoolean(value: Array<boolean>): TestAttribute255
256// testArrayRefNumber(value: Array<number>): TestAttribute257
258// // testArrayTuple(value: Array<[number, boolean]>): TestAttribute259
260// // interface261
262testBooleanInterface(value: BooleanInterfaceDTS): TestAttribute263
264testNumberInterface(value: NumberInterfaceDTS): TestAttribute265
266testStringInterface(value: StringInterfaceDTS): TestAttribute267
268testUnionInterface(value: UnionInterfaceDTS): TestAttribute269
270testUnionOptional(value: UnionOptionalInterfaceDTS): TestAttribute271
272testTupleInterface(value: TupleInterfaceDTS): TestAttribute273
274testTupleInterface(value: TestTupleUnionInterfaceDTS): TestAttribute275
276testOptionInterface(value: OptionInterfaceDTS): TestAttribute277
278testOptionInterface(value: OptionalTestInterface): TestAttribute279
280// testArrayRefNumberInterface(value: ArrayRefNumberInterfaceDTS): TestAttribute281
282// // testArrayRefTupleInterface(value: ArrayRefTuplesInterfaceDTS)283
284
285// // Boolean Interface286
287// testBooleanInterfaceOption(value?: BooleanInterfaceDTS): TestAttribute288
289// testBooleanInterfaceTuple(value: [BooleanInterfaceDTS]): TestAttribute290
291// testBooleanInterfaceArray(value: BooleanInterfaceDTS[]): TestAttribute292
293// testBooleanInterfaceArrayRef(value: Array<BooleanInterfaceDTS>): TestAttribute294
295testInterfaceMixed(v1: UnionInterfaceDTS, v2: number, v3: TupleInterfaceDTS): TestAttribute296
297// // Class298
299// testClass(value: ClassDTS): TestAttribute300
301// testClassWithConstructor(value: ClassWithConstructorDTS): TestAttribute302
303// testClassWithConstructorAndFields(value: ClassWithConstructorAndFieldsDTS): TestAttribute304
305// // Materialized class306
307// testClassWithConstructorAndMethods(value: ClassWithConstructorAndMethodsDTS): TestAttribute308
309// testClassWithConstructorAndStaticMethods(value: ClassWithConstructorAndStaticMethodsDTS): TestAttribute310
311// testClassWithConstructorAndFieldsAndMethods(value: ClassWithConstructorAndFieldsAndMethodsDTS): TestAttribute312
313// testClassWithConstructorAndNonOptionalParams(value: ClassWithConstructorAndNonOptionalParamsDTS): TestAttribute314
315// testClassWithConstructorAndSomeOptionalParams(value: ClassWithConstructorAndSomeOptionalParamsDTS): TestAttribute316
317// testClassWithConstructorAndAllOptionalParams(value: ClassWithConstructorAndAllOptionalParamsDTS): TestAttribute318
319// testClassWithConstructorAndWithoutParams(value: ClassWithConstructorAndWithoutParamsDTS): TestAttribute320}
321