1/* 2 * Copyright (c) 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 16interface PersonInfoInterface1{ 17 age1:number 18 salary1:number 19} 20 21interface PersonInfoInterface2{ 22 age2:PersonInfoInterface1 23 salary2:number 24} 25 26interface PersonInfoInterface3{ 27 age3:PersonInfoInterface2 28 salary3:number 29} 30 31function assertsalary1(inputval:PersonInfoInterface1|undefined, salary:int){ 32 if(inputval instanceof undefined){ 33 assert(false) 34 } 35 let returnval = inputval as PersonInfoInterface1; 36 assert(returnval.salary1 == salary) 37} 38 39function assertsalary3(inputval:PersonInfoInterface3|undefined, salary:int){ 40 if(inputval instanceof undefined){ 41 assert(false) 42 } 43 let returnval = inputval as PersonInfoInterface3; 44 assert(returnval.salary3 == salary) 45} 46 47function main(){ 48 let personMap1:Record<string, PersonInfoInterface1> = { 49 "john":{age1:25, salary1:10}, 50 "Mary":{age1:21, salary1:20} 51 }; 52 assertsalary1(personMap1.get("john"), 10); 53 54 let nestedObjectMap:Record<string, PersonInfoInterface3> = { 55 "john":{age3:{age2:{age1:10,salary1:10},salary2:10},salary3:10}, 56 "Mary":{age3:{age2:{age1:10,salary1:10},salary2:10},salary3:10} 57 }; 58 assertsalary3(nestedObjectMap.get("john"), 10); 59}