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 16import {a} from './a'; 17import * as b from './b'; 18export let c; 19export * from './d'; 20export {e} from './e'; 21 22class HelloWorld { 23 str = 'HelloWorld'; 24} 25 26class Lit { 27 *lit(): Generator<never, void, unknown> {} 28} 29 30class NestedLiteralArray { 31 num: number = 1; 32 NestedLiteralArray(): void {} 33 constructor() { 34 'use sendable'; 35 } 36} 37 38msg : string = ''; 39 40function foo(): void { 41 try { 42 varA = 11; 43 x = 22; 44 try { 45 varA = 1; 46 } catch (e) { 47 msg = 'inner catch'; 48 print(msg); 49 } 50 if (varA === '') { 51 throw 'null'; 52 } 53 if (x > 100) { 54 throw 'max'; 55 } else { 56 throw 'min'; 57 } 58 } 59 catch (err) { 60 masg = 'outter catch'; 61 print(msg); 62 } 63 finally { 64 msg = 'error'; 65 print(msg); 66 } 67} 68 69function goo(): void {} 70 71function hoo(): void { 72 varA = 1.23; 73 let obj = {async * method(): AsyncGenerator<never, void, unknown> {}}; 74} 75 76let add = (a: number, b: number): number => a + b; 77add(1, 2); 78 79function* generateFunc(): Generator<string, void, unknown> { 80 yield 'hello'; 81} 82 83async function* asyncGenerateFunc(): AsyncGenerator<string, void, unknown> { 84 yield 'hello'; 85} 86 87const asyncArrowFunc = async (): Promise<void> => {}; 88 89foo(); 90 91print(goo.toString()); 92 93hoo();