• 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/members/objectTypeHidingMembersOfObject.ts ===
20declare function AssertType(value:any, type:string):void;
21// all of these valueOf calls should return the type shown in the overriding signatures here
22
23class C {
24    valueOf() { }
25}
26
27let c: C;
28AssertType(c, "C");
29
30let r1: void = c.valueOf();
31AssertType(r1, "void");
32AssertType(c.valueOf(), "void");
33AssertType(c.valueOf, "() => void");
34
35interface I {
36    valueOf(): void;
37}
38
39let i: I;
40AssertType(i, "I");
41
42let r2: void = i.valueOf();
43AssertType(r2, "void");
44AssertType(i.valueOf(), "void");
45AssertType(i.valueOf, "() => void");
46
47let a = {
48AssertType(a, "{ valueOf: () => void; }");
49AssertType({    valueOf: () => { }}, "{ valueOf: () => void; }");
50
51    valueOf: () => {
52AssertType(valueOf, "() => void");
53
54AssertType(() => { }, "() => void");
55}
56}
57
58let r3: void = a.valueOf();
59AssertType(r3, "void");
60AssertType(a.valueOf(), "void");
61AssertType(a.valueOf, "() => void");
62
63let b: {
64AssertType(b, "{ valueOf(): void; }");
65
66    valueOf(): void;
67AssertType(valueOf, "() => void");
68}
69
70let r4: void = b.valueOf();
71AssertType(r4, "void");
72AssertType(b.valueOf(), "void");
73AssertType(b.valueOf, "() => void");
74
75
76