1/* 2 * Copyright (c) 2022-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 16import { ff, doSomething, TestClassC, TestClassD } from "./oh_modules/ohos_lib"; 17import { f, f2, bar, applyToUnknown, fooExecute, C1, resourceFoo, ResourceStr, myFoo, myFoo2 } from "./dynamic_lib"; 18 19let a1: C1 = new C1() 20 21function g1(): C1 | undefined { 22 if (a1) { 23 return a1 24 } 25 return undefined 26} 27 28f2(g1()) 29 30bar(undefined); 31bar(undefined, undefined); 32applyToUnknown(undefined); 33fooExecute(undefined); 34 35function fff(a: Array<number>): void {} 36 37fff(undefined); 38ff(undefined); 39f(undefined); 40 41function resourceFoo2(a: ResourceStr) { return "0" } 42 43class A { 44 buttonTitle1?: string; 45 buttonTitle2?: string; 46 buttonTitle3?: string; 47 48 constructor(menu?: Partial<A>) { 49 this.buttonTitle1 = resourceFoo(menu?.buttonTitle1); 50 this.buttonTitle2 = resourceFoo(menu?.buttonTitle2); 51 this.buttonTitle3 = resourceFoo2(menu?.buttonTitle3); 52 } 53} 54 55myFoo({x: "", y: undefined}) 56 57class A2 { 58 public a: Object = undefined 59 f() { 60 myFoo2( 61 () => { 62 this.a = undefined; 63 } 64 ) 65 } 66} 67 68class TestClassB { 69 private c:TestClassD | undefined = new TestClassD(); 70 add() { 71 doSomething({ 72 topic: (topic: string) => { 73 let a = new TestClassC(); 74 this.c = a; 75 this.c = a; 76 } 77 }, ''); 78 } 79} 80