1/* 2 * Copyright (c) 2024-2025 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 16function f1(a: int, ...b: int[] = 47): bool { 17 console.log(a, b...); 18 let x = (x instanceof A<string); 19 return x instanceof A<int>; 20} 21 22function f2(a?: int = 44): void {} 23 24function f3(a: int = ): void; 25 26function f4() { 27 55 = int; 28 69++ 29 --58 30 78 = type 31} 32 33function f5(...b: int[] = 47, c?: int = 88): void {} 34 35let x = (: int => { return 7; } 36 37let x: number => 77 38let x = new int(7); 39let x = new int{8}; 40 41interface C { 42 f(a: int = 0): void; 43} 44 45class A { 46 f1(): void { 47 async x = 9 48 } 49 50 f2() { 51 this.99++; 52 } 53} 54 55function f6(a: int = 9 @@): void; 56 57function f7(a: (b: int = 0) => int): void { 58} 59 60/* @@? 16:35 Error SyntaxError: Rest parameter cannot have the default value. */ 61/* @@? 16:37 Error SyntaxError: Identifier is needed here. */ 62/* @@? 16:40 Error TypeError: Cannot find type 'bool'. */ 63/* @@? 17:20 Error TypeError: Unresolved reference b */ 64/* @@? 17:21 Error SyntaxError: Unexpected token '...'. */ 65/* @@? 17:21 Error SyntaxError: Unexpected token, expected ',' or ')'. */ 66/* @@? 17:24 Error SyntaxError: Unexpected token ')'. */ 67/* @@? 18:13 Error TypeError: Bad operand type, the types of the operands must be numeric, same enumeration, or boolean type. */ 68/* @@? 18:13 Error TypeError: Circular dependency detected for identifier: x */ 69/* @@? 18:14 Error TypeError: Variable 'x' is accessed before it's initialization. */ 70/* @@? 18:35 Error SyntaxError: Unexpected token, expected '>'. */ 71/* @@? 18:36 Error SyntaxError: Unexpected token ';'. */ 72/* @@? 18:36 Error SyntaxError: Unexpected token, expected ')'. */ 73/* @@? 19:12 Error TypeError: Bad operand type, the types of the operands must be same type. */ 74/* @@? 19:25 Error Warning: Type parameter is erased from type 'A' when used in instanceof expression. */ 75/* @@? 22:23 Error SyntaxError: Not enable default value with default undefined. */ 76/* @@? 24:10 Error TypeError: Only abstract or native methods can't have body. */ 77/* @@? 24:22 Error SyntaxError: You didn't set the value. */ 78/* @@? 24:22 Error SyntaxError: Unexpected token ')'. */ 79/* @@? 27:5 Error TypeError: Invalid left-hand side of assignment expression */ 80/* @@? 27:8 Error SyntaxError: Invalid left-hand side in assignment expression. */ 81/* @@? 28:7 Error SyntaxError: Invalid left-hand side operator. */ 82/* @@? 30:5 Error TypeError: Invalid left-hand side of assignment expression */ 83/* @@? 30:5 Error SyntaxError: Invalid left-hand side in prefix operation. */ 84/* @@? 30:8 Error SyntaxError: Invalid left-hand side in assignment expression. */ 85/* @@? 33:27 Error SyntaxError: Rest parameter cannot have the default value. */ 86/* @@? 33:29 Error SyntaxError: Identifier is needed here. */ 87/* @@? 33:41 Error SyntaxError: Not enable default value with default undefined. */ 88/* @@? 35:10 Error SyntaxError: Unexpected token ':'. */ 89/* @@? 35:10 Error SyntaxError: Unexpected token, expected ')'. */ 90/* @@? 35:12 Error SyntaxError: Unexpected token 'int'. */ 91/* @@? 35:16 Error SyntaxError: Unexpected token '=>'. */ 92/* @@? 37:5 Error TypeError: Variable 'x' has already been declared. */ 93/* @@? 37:15 Error SyntaxError: Unexpected token '=>'. */ 94/* @@? 38:5 Error TypeError: Variable 'x' has already been declared. */ 95/* @@? 38:9 Error TypeError: This expression is not constructible. */ 96/* @@? 39:5 Error TypeError: Variable 'x' has already been declared. */ 97/* @@? 39:9 Error TypeError: This expression is not constructible. */ 98/* @@? 39:16 Error SyntaxError: Unexpected token '{'. */ 99/* @@? 47:15 Error SyntaxError: Unexpected token, expected '('. */ 100/* @@? 47:17 Error SyntaxError: Unexpected token, expected an identifier. */ 101/* @@? 48:5 Error SyntaxError: Unexpected token, expected ',' or ')'. */ 102/* @@? 48:5 Error SyntaxError: Expected '=>', got '}'. */ 103/* @@? 48:5 Error SyntaxError: Unexpected token '}'. */ 104/* @@? 51:13 Error SyntaxError: Unexpected token '.99'. */ 105/* @@? 51:16 Error SyntaxError: Invalid left-hand side operator. */ 106/* @@? 55:10 Error TypeError: Only abstract or native methods can't have body. */ 107/* @@? 55:24 Error SyntaxError: Unexpected token '@@'. */ 108/* @@? 55:24 Error SyntaxError: Unexpected token, expected ',' or ')'. */ 109/* @@? 55:26 Error SyntaxError: Unexpected token ')'. */ 110/* @@? 55:27 Error SyntaxError: Unexpected token ':'. */ 111/* @@? 55:29 Error TypeError: Unresolved reference void */ 112/* @@? 57:26 Error SyntaxError: Default value is allowed only for optional parameters. */ 113