• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) Microsoft Corporation. All rights reserved.
3* Copyright (c) 2023 Huawei Device Co., Ltd.
4* Licensed under the Apache License, Version 2.0 (the "License");
5* you may not use this file except in compliance with the License.
6* You may obtain a copy of the License at
7*
8*     http://www.apache.org/licenses/LICENSE-2.0
9*
10* Unless required by applicable law or agreed to in writing, software
11* distributed under the License is distributed on an "AS IS" BASIS,
12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13* See the License for the specific language governing permissions and
14* limitations under the License.
15*
16* This file has been modified by Huawei to verify type inference by adding verification statements.
17*/
18
19// === tests/cases/conformance/types/objectTypeLiteral/callSignatures/parametersWithNoAnnotationAreAny.ts ===
20declare function AssertType(value:any, type:string):void;
21function foo(x) {
22AssertType(x, "any");
23return x;
24}
25
26let f = function foo(x) {
27AssertType(f, "(any) => any");
28return x;
29
30AssertType(function foo(x) { return x; }, "(any) => any");
31
32AssertType(foo, "(any) => any");
33
34AssertType(x, "any");
35
36AssertType(x, "any");
37}
38
39let f2 = (x) => x;
40AssertType(f2, "(any) => any");
41AssertType((x) => x, "(any) => any");
42AssertType(x, "any");
43AssertType(x, "any");
44
45let f3 = <T>(x) => x;
46AssertType(f3, "<T>(any) => any");
47AssertType(<T>(x) => x, "<T>(any) => any");
48AssertType(x, "any");
49AssertType(x, "any");
50
51class C {
52    foo(x) {
53AssertType(x, "any");
54        return x;
55    }
56}
57
58interface I {
59    foo(x);
60    foo2(x, y);
61}
62
63let a: {
64AssertType(a, "{ foo(any): any; }");
65
66    foo(x);
67AssertType(foo, "(any) => any");
68AssertType(x, "any");
69}
70
71let b = {
72AssertType(b, "{ foo(any): any; a: (any) => any; b: (any) => any; }");
73AssertType({    foo(x) {        return x;    },    a: function foo(x) {        return x;    },    b: (x) => x}, "{ foo(any): any; a: (any) => any; b: (any) => any; }");
74
75    foo(x) {
76AssertType(foo, "(any) => any");
77AssertType(x, "any");
78
79AssertType(x, "any");
80        return x;
81
82    },
83    a: function foo(x) {
84AssertType(a, "(any) => any");
85AssertType(foo, "(any) => any");
86AssertType(x, "any");
87AssertType(function foo(x) {        return x;    }, "(any) => any");
88
89AssertType(x, "any");
90        return x;
91
92    },
93    b: (x) => x
94AssertType(b, "(any) => any");
95AssertType((x) => x, "(any) => any");
96AssertType(x, "any");
97AssertType(x, "any");
98}
99
100