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 { Something, SomethingFactory, SomethingBar, Bar, Select } from "./oh_modules/ohos_factory"; 17 18class C { 19 static a = 5 20 static b = 8 21} 22 23namespace H { 24 export class G {} 25} 26 27let c = C 28c = C 29let g = H.G 30g = H.G 31 32let ca = C.a 33let cb = C.b 34 35let cc = new C() 36let gg = new H.G() 37 38function foo1(arg: typeof C) {} 39foo1(C) 40 41function foo2(arg: C) { 42 return C 43} 44 45function foo3(arg: typeof H.G) {} 46foo3(H.G) 47 48function foo4(arg: H.G) { 49 return H.G 50} 51 52class A {} 53interface B {} 54interface I {} 55class CC extends A implements I, B {} 56 57class D { 58 constructor(arg: typeof C) {} 59} 60new D(C) 61 62type X = D; 63 64namespace test1 { 65 class SomethingFoo extends Something { } 66 namespace NS { export class SomethingFoo extends Something { } } 67 68 let fact = SomethingFactory.getInstance(); 69 70 let x1 = fact.create1(SomethingFoo).beep(); 71 let x2 = fact.create1(SomethingBar).beep(); 72 let x3 = fact.create1(NS.SomethingFoo).beep(); 73 74 let x4 = fact.create2({ o: SomethingFoo }); 75 let x5 = fact.create2({ o: SomethingBar }); 76 let x6 = fact.create2({ o: NS.SomethingFoo }); 77 78 let x7 = fact.create3(() => SomethingFoo); 79 let x8 = fact.create4(() => SomethingFoo); 80 81 let x9 = new Bar(SomethingFoo); 82} 83 84enum Color { WHITE, BLUE, RED }; 85let color: Color = Color.RED; 86 87for (let item = 0; item < Object.keys(Color).length; item++) { 88 console.log(item); 89} 90 91foo2(() => C); 92 93export { C as H }; 94 95// #14228 96let data = new Select<Object>().from(C).eq('key').query(C); // Ok 97invalid_func(C); // Ok 98let a: any; 99a.foo(C); // Ok 100 101let col = 'WHITE'; 102console.log(Color[col]) 103 104// #14184 105namespace NS { 106 export enum E { 107 A = 'A', 108 B = 'B', 109 C = 'C' 110 } 111} 112 113let s: string = 'B'; 114let s2: string = NS.E[s]; 115 116for (let item = 0; item < Object.keys(NS.E).length; item++) { 117 console.log(item); 118} 119 120/** 121 * {@link C} - should not report error 122 */ 123class JSDocClass {}