• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-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
16type FuncType = (p: string) => void;
17
18 let f1: FuncType = p => {
19    return 0;
20 }
21
22 let f2: FuncType = (p: string): void => {
23    ((p) => {
24        return 0;
25    })(p);
26 }
27
28 f1 = (p: string): number => {
29    return 0;
30 }
31
32 f2 = (p: string): void => {
33    ((p: string): number => {
34        return 0;
35    })(p);
36 }
37
38 let f3: (p: string) => number = p => {
39    return 0;
40 }
41
42 f1 = f3;
43
44 f2 = (p: string): void => {
45    f3(p);
46 };
47
48 type FuncType2 = (p: string) => number;
49
50 let f4 : FuncType | FuncType2 = p => {
51    return 0;
52 }
53
54 type FuncType3 = (p:string, q:string) => void
55
56 let f5: FuncType3 = (p, q) => {
57    return 0;
58 }
59
60 f5 = (p:string, q:string):number => {
61    return 0;
62 }
63
64type FuncTypeWithOptionalParam = (p?: string, q: number = 0) => void;
65
66let f6: FuncTypeWithOptionalParam = (p, q) => {
67    return 0;
68};
69
70type BaseType = (p: string) => number;
71type WrappedType = BaseType;
72type FinalType = WrappedType;
73
74let f7: FinalType = (p) => {
75    return 0;
76}
77
78type FuncTypeNoParams = () => void;
79
80let fNoParams: FuncTypeNoParams = () => {
81    return 0;
82};