/* * Copyright (c) 2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ class C { constructor (p: T) { this.v = p; } v: T; } type Alias1Tuple = [T]; type Alias2Tuple = [T, Int]; type Alias3Tuple = [C, double]; type Alias4Tuple = [T1[], T2]; type Alias5Tuple = [C[], T2]; type Alias6Tuple = [(p: T1) => double, T2]; function main() { let v1: [double] = [new Int(1)]; // [double] let v2: [double, Int] = [new Double(2), new Int(3)]; // [Double, Int] let v3: Alias1Tuple = [new Int(4)]; // [double] let v4: Alias2Tuple = [new Double(5), new Int(6)]; // [Double, Int] let v5: Alias3Tuple = [new C(7), 8]; // [C, Double] assert(v5[0].v == 7); assert(v5[1] == 8); let v6: Alias4Tuple = [[new Int(9), new Int(10), new Int(11)], 12]; // [double[], Double] assert(v6[0][0] == 9); assert(v6[0][1] == 10); assert(v6[0][2] == 11); assert(v6[1] == 12); let v7: Alias5Tuple = [[new C(13)], 14]; // [C[], Double] assert(v7[0][0].v == 13); assert(v7[1] == 14); let v9: Alias6Tuple = [(p: double) : double => { return p;}, 16]; // [(p: Double) => Double, Double] assert(v9[0](15) == 15); assert(v9[1] == 16); }