/* * 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; } class D { constructor (p: T1, q: T2) { this.v = p; this.w = q; } v : T1; w : T2; } type AliasPrimitive = T; type AliasAlias = AliasPrimitive; type Alias1Class = C; type Alias2Class = C; type Alias3Class = D; type Alias4Class = D; type Alias5Class = D, AliasAlias[]> function main() { let v1 : C = new C(1); // C assert(v1.v == 1); let v2 : Alias1Class = new C(2); // C assert(v2.v == 2); let v3 : Alias2Class = new C([3.0]); // C assert(v3.v[0] == 3); let v4: Alias3Class = new D(4.0, 5); // D assert(v4.v == 4.0); assert(v4.w == 5); let v5: Alias4Class = new D(6, 7.0); // D assert(v5.v == 6); assert(v5.w == 7.0); let v6: Alias5Class = new D, double[]>(new C(8), [9.0]); // D, double[]> assert(v6.v.v == 8); assert(v6.w[0] == 9.0); }