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 16try { 17 let x = 8 18} 19 20try {} 21finally (x) 22 23try {} 24catch () {} 25 26declare namespace abc { 27 let i = 0 28} 29 30function f(): void { 31 abstract function s(): void {} 32} 33 34function f(): void { 35 module "module1" let x = 99; 36} 37 38interface A { 39 a: number; 40 a: char; 41} 42 43class A { 44 declare [index: string]]: string; 45 46 @decorator 47 [index: string]]: MyType; 48 49 @decorator 50 private x: number; 51 52 @decorator 53 constructor() {} 54 55 x! number; 56} 57 58class A { 59 [index: number]]?: string; 60 61 constructor?(x: number) {} 62} 63 64class A implements A. {} 65 66const x: number; 67 68let [x, y]; 69 70enum A 71 I1, 72 I2, 73 123, 74 123 = 55, 75 I3 = , 76 I4 77} 78 79class A<123> {} 80 81class A<T = Number, S> {} 82 83class A<> {} 84 85class B { 86 abstract class C; 87 88 private public x: number; 89 protected protected x: number; 90 91 constructor(static x: number) {} 92} 93 94let f = (a?: number, a: string) => {}; 95let f = (arguments: bool[], eval: bool) => {}; 96let f = ([a!, [b]?, c?]) => {}; 97let f = (a?: [c: int, d?: char]) => {}; 98let f = ({a: 123, b: bool}) => {}; 99let f = (a: int = await 10, a?: int = 2) => {}; 100 101declare namespace abc { 102 let a = 8; 103} 104 105module { 106 declare function s(): void; 107} 108 109module module2 110 declare namespace abc {} 111// This should be the last test to show the absent of the '}'. 112 113/* @@? 20:1 Error SyntaxError: Missing catch or finally clause. */ 114/* @@? 21:9 Error SyntaxError: Expected a '{', got '('. */ 115/* @@? 24:8 Error SyntaxError: Unexpected token ')' in catch parameter. */ 116/* @@? 27:13 Error SyntaxError: Initializers are not allowed in ambient contexts. */ 117/* @@? 31:14 Error SyntaxError: abstract modifier can only appear on a class, struct, method, or property declaration. */ 118/* @@? 35:12 Error SyntaxError: Only ambient modules can use quoted names */ 119/* @@? 35:22 Error SyntaxError: Unexpected token, expected: ';'. */ 120/* @@? 40:5 Error SyntaxError: Duplicated identifier */ 121/* @@? 44:37 Error SyntaxError: 'declare' modifier cannot appear on an index signature. */ 122/* @@? 46:5 Error SyntaxError: Decorators are not valid here. */ 123/* @@? 52:5 Error SyntaxError: Decorators are not valid here. */ 124/* @@? 55:6 Error SyntaxError: Unexpected token, expected: ';'. */ 125/* @@? 55:8 Error SyntaxError: Unexpected token, expected: ';'. */ 126/* @@? 59:21 Error SyntaxError: Unexpected token, expected: ';'. */ 127/* @@? 61:5 Error SyntaxError: Classes may not have a field named 'constructor' */ 128/* @@? 61:16 Error SyntaxError: Unexpected token, expected: '('. */ 129/* @@? 64:23 Error SyntaxError: Identifier expected */ 130/* @@? 64:23 Error SyntaxError: Implements clause can not be empty */ 131/* @@? 66:16 Error SyntaxError: Missing initializer in const declaration */ 132/* @@? 68:11 Error SyntaxError: Missing initializer in destructuring declaration */ 133/* @@? 71:5 Error SyntaxError: Unexpected token, expected: '{'. */ 134/* @@? 71:7 Error SyntaxError: Unexpected token in enum member */ 135/* @@? 73:5 Error SyntaxError: Unexpected token in enum member */ 136/* @@? 74:5 Error SyntaxError: Unexpected token in enum member */ 137/* @@? 75:10 Error SyntaxError: Unexpected token: ','. */ 138/* @@? 79:9 Error SyntaxError: Type parameter declaration expected */ 139/* @@? 79:9 Error SyntaxError: Unexpected token, expected: '>'. */ 140/* @@? 79:12 Error SyntaxError: Unexpected token, expected: '{'. */ 141/* @@? 79:14 Error SyntaxError: Unexpected token in class property */ 142/* @@? 81:7 Error SyntaxError: Unexpected token, expected: ';'. */ 143/* @@? 81:8 Error SyntaxError: Unexpected token in class property */ 144/* @@? 81:11 Error SyntaxError: Unexpected token in class property */ 145/* @@? 81:19 Error SyntaxError: Unexpected token in class property */ 146/* @@? 81:22 Error SyntaxError: Unexpected token in class property */ 147/* @@? 83:9 Error SyntaxError: Type parameter list cannot be empty. */ 148/* @@? 86:14 Error SyntaxError: Abstract methods can only appear within an abstract class. */ 149/* @@? 86:20 Error SyntaxError: Unexpected token, expected: ';'. */ 150/* @@? 88:13 Error SyntaxError: Unexpected modifier */ 151/* @@? 89:15 Error SyntaxError: Unexpected modifier */ 152/* @@? 89:15 Error SyntaxError: Duplicated modifier is not allowed */ 153/* @@? 91:17 Error SyntaxError: 'static' modifier cannot appear on a parameter. */ 154/* @@? 94:22 Error SyntaxError: A required parameter cannot follow an optional parameter. */ 155/* @@? 95:41 Error SyntaxError: Binding 'arguments' in strict mode is invalid */ 156/* @@? 95:10 Error SyntaxError: 'eval' or 'arguments' can't be defined or assigned to in strict mode code */ 157/* @@? 95:41 Error SyntaxError: Binding 'eval' in strict mode is invalid */ 158/* @@? 95:29 Error SyntaxError: 'eval' or 'arguments' can't be defined or assigned to in strict mode code */ 159/* @@? 96:18 Error SyntaxError: Unexpected '?' for parameter */ 160/* @@? 96:26 Error SyntaxError: Invalid destructuring assignment target */ 161/* @@? 96:26 Error SyntaxError: Unexpected ArrowParameter element */ 162/* @@? 96:26 Error SyntaxError: Unexpected ArrowParameter element */ 163/* @@? 98:29 Error SyntaxError: Invalid destructuring assignment target */ 164/* @@? 99:42 Error SyntaxError: await is not allowed in arrow function parameters */ 165/* @@? 99:29 Error SyntaxError: Parameter cannot have question mark and initializer. */ 166/* @@? 102:13 Error SyntaxError: Initializers are not allowed in ambient contexts. */ 167/* @@? 105:8 Error SyntaxError: Unexpected token, expected an identifier. */ 168/* @@? 106:5 Error SyntaxError: Unexpected token, expected: '{'. */ 169/* @@? 110:5 Error SyntaxError: Unexpected token, expected: '{'. */ 170/* @@? 172:1 Error SyntaxError: Unexpected token, expected: '}'. */ 171/* @@? 172:1 Error SyntaxError: Expected a '}' got 'eos'. */ 172