• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16class A<T, U, K> {
17    public a: T;
18    public b: U;
19    public c: K;
20
21    constructor(a: T, b: U, c: K) {
22        this.a = a;
23        this.b = b;
24        this.c = c;
25    }
26}
27
28function bar<T>(a: T): T {
29    return a;
30}
31
32function foo<T, U, K>(a: A<A<K, U, T>, String, K>): void {
33    assert ((typeof a.a) == "object");
34    assert ((typeof a.b) == "string");
35    assert ((typeof a.c) == "boolean");
36    assert ((typeof a.a.a) == "boolean");
37    assert ((typeof a.a.b) == "string");
38    assert ((typeof a.a.c) == "int");
39}
40
41function main(): void {
42    let a = new A<A<Boolean, String, Int>, string, boolean>(new A<Boolean, String, Int>(bar(true), "alma", 20), "korte", true);
43    foo(a);
44}
45