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/typeRelationships/typeAndMemberIdentity/objectTypesIdentity2.ts === 20declare function AssertType(value:any, type:string):void; 21// object types are identical structurally 22 23class A { 24 foo: number; 25} 26 27class B { 28 foo: boolean; 29} 30 31class C<T> { 32 foo: T; 33} 34 35interface I { 36 foo: Date; 37} 38 39let a: { foo: RegExp; 40AssertType(a, "{ foo: RegExp; }"); 41 42AssertType(foo, "RegExp"); 43} 44 45enum E { A } 46let b = { foo: E.A }; 47AssertType(b, "{ foo: E; }"); 48AssertType({ foo: E.A }, "{ foo: E; }"); 49AssertType(foo, "E"); 50AssertType(E.A, "E"); 51 52function foo5(x: A); 53function foo5(x: B); // ok 54function foo5(x: any) { } 55 56function foo5b(x: A); 57function foo5b(x: C<string>); // ok 58function foo5b(x: any) { } 59 60function foo6(x: A); 61function foo6(x: I); // ok 62function foo6(x: any) { } 63 64function foo7(x: A); 65function foo7(x: typeof a); // ok 66function foo7(x: any) { } 67 68function foo8(x: B); 69function foo8(x: I); // ok 70function foo8(x: any) { } 71 72function foo9(x: B); 73function foo9(x: C<string>); // ok 74function foo9(x: any) { } 75 76function foo10(x: B); 77function foo10(x: typeof a); // ok 78function foo10(x: any) { } 79 80function foo11(x: B); 81function foo11(x: typeof b); // ok 82function foo11(x: any) { } 83 84function foo12(x: I); 85function foo12(x: C<string>); // ok 86function foo12(x: any) { } 87 88function foo13(x: I); 89function foo13(x: typeof a); // ok 90function foo13(x: any) { } 91 92function foo14(x: I); 93function foo14(x: typeof b); // ok 94function foo14(x: any) { } 95 96