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/assignmentCompatibility/assignmentCompatWithObjectMembers.ts === 20declare function AssertType(value:any, type:string):void; 21 22// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M 23// no errors expected 24 25module SimpleTypes { 26 class S { foo: string; } 27 class T { foo: string; } 28 let s: S; 29 let t: T; 30 31 interface S2 { foo: string; } 32 interface T2 { foo: string; } 33 let s2: S2; 34 let t2: T2; 35 36 let a: { foo: string; } 37 let b: { foo: string; } 38 39 let a2 = { foo: '' }; 40 let b2 = { foo: '' }; 41 42 s = t; 43 t = s; 44 s = s2; 45 s = a2; 46 47 s2 = t2; 48 t2 = s2; 49 s2 = t; 50 s2 = b; 51 s2 = a2; 52 53 a = b; 54 b = a; 55 a = s; 56 a = s2; 57 a = a2; 58 59 a2 = b2; 60 b2 = a2; 61 a2 = b; 62 a2 = t2; 63 a2 = t; 64} 65 66module ObjectTypes { 67 class S { foo: S; } 68 class T { foo: T; } 69 let s: S; 70 let t: T; 71 72 interface S2 { foo: S2; } 73 interface T2 { foo: T2; } 74 let s2: S2; 75 let t2: T2; 76 77 let a: { foo: typeof a; } 78 let b: { foo: typeof b; } 79 80 let a2 = { foo: a2 }; 81 let b2 = { foo: b2 }; 82 83 s = t; 84 t = s; 85 s = s2; 86 s = a2; 87 88 s2 = t2; 89 t2 = s2; 90 s2 = t; 91 s2 = b; 92 s2 = a2; 93 94 a = b; 95 b = a; 96 a = s; 97 a = s2; 98 a = a2; 99 100 a2 = b2; 101 b2 = a2; 102 a2 = b; 103 a2 = t2; 104 a2 = t; 105 106} 107 108