• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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
17function func1<Type, A, B extends readonly number[]>(arg: Type): Type {
18    return arg;
19}
20
21function func2<A extends { a: number, b: string }>() { }
22
23function func3<A extends keyof { a: { b: number, c: boolean }, b: [number, string] }>(a: A, b: string): number | boolean {
24    return true;
25}
26
27declare type PromiseConstructorLike = new <T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void) => PromiseLike<T>;
28
29interface R<K extends [number, string], T = string> {
30    a: number,
31    [x: string]: boolean | number,
32}
33
34interface U<A extends readonly [number, number, { a: number, b: string }], Z = boolean> extends R<[number, string]> {
35    <A>(): number,
36    o<A extends number>(): [boolean, number[]];
37}
38
39func1<number, string, [1, 2, 3]>()
40func2<<A>() => {}>();
41
42var o = {
43    a: function <B, C extends typeof func1>() { },
44    b: function <D = number, T = string>() { },
45    c<E, F extends readonly []>() { }
46}
47
48class A<T extends B, Z = { a: number, b: string }> {
49    public a<T, R>() { };
50    private b<E extends (a: number, b: string) => any[]>() { }
51}
52
53class W extends T<<B> () => number, [number | string][]> {
54
55}
56
57class X extends Q<number> implements S<<R>(a:number, b:string) => [number]>, A {
58
59}
60
61var a: new <A>() => <B>() => string;
62var b: <A extends T, U = 5>(a: number | string) => { a: number };
63
64var c: B.T<A<C<number>>>[0];
65var d: A<number, { a: number, b: string }, [number, string]>;
66var e: T<<A>() => {}>;
67
68type E<R extends B, C, T = number> = number | T | string;
69type P<K, Q = [number, number, string] | any[]> = {a:K, b:Q};
70
71async<<A>() => {}>();
72p<number>();
73<A extends B>():number => true;
74async<A extends readonly [number, string]>() => {return "foo";};
75