• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16class A {
17    static static f(): void;
18    native native f2(): void {
19        console.log(f);
20    }
21
22    static private abstract static f3(): int {
23        return 7
24    }
25
26    native async f4();
27    async abstract f5();
28
29    static {
30        let x: number = 99
31    }
32
33    static {
34        let y: number = 75
35    }
36}
37
38abstract abstract class B {
39    x: number = 77;
40
41    async $_get(): int {
42        return 5;
43    }
44
45    async $_set(): void;
46
47    async $_iterator(a: int): int {
48        return a + 1;
49    }
50}
51
52declare namespace abc {
53    class C {
54        x: number = 53;
55    }
56}
57
58declare native class Z {}
59
60function s(): void {
61    class C {
62        private x: number;
63    }
64
65    interface I {
66        private f(): void;
67        static static g(): void;
68    }
69}
70
71interface I1 {
72    class A {}
73
74    get color(): string {
75        return "red";
76    }
77
78    x: number =
79}
80
81/* @@? 16:9 Error TypeError: A is not abstract and does not override abstract method f5(): Promise<void> in A */
82/* @@? 17:12 Error SyntaxError: Duplicated modifier is not allowed. */
83/* @@? 17:20 Error TypeError: Only abstract or native methods can't have body. */
84/* @@? 18:12 Error SyntaxError: Duplicated modifier is not allowed. */
85/* @@? 18:30 Error TypeError: Native, Abstract and Declare methods cannot have body. */
86/* @@? 19:21 Error TypeError: Static property 'f' must be accessed through it's class 'A' */
87/* @@? 22:12 Error SyntaxError: Access modifier must precede field and method modifiers. */
88/* @@? 22:20 Error TypeError: Invalid method modifier(s): an abstract method can't have private, override, static, final or native modifier. */
89/* @@? 22:46 Error TypeError: Native, Abstract and Declare methods cannot have body. */
90/* @@? 26:18 Error SyntaxError: Native method cannot be async. */
91/* @@? 27:5 Error TypeError: Non abstract class has abstract method. */
92/* @@? 27:20 Error SyntaxError: Abstract method cannot be async. */
93/* @@? 35:5 Error SyntaxError: Only one static block is allowed in one namespace or class. */
94/* @@? 38:10 Error SyntaxError: Duplicated modifier is not allowed. */
95/* @@? 41:5 Error SyntaxError: The special predefined method '$_get' should have exactly one required parameter. */
96/* @@? 41:5 Error SyntaxError: The special predefined method '$_get' cannot be asynchronous. */
97/* @@? 41:16 Error TypeError: Return type of async function must be 'Promise'. */
98/* @@? 45:5 Error SyntaxError: The special predefined method '$_set' should have exactly two required parameter. */
99/* @@? 45:5 Error SyntaxError: The special predefined method '$_set' cannot be asynchronous. */
100/* @@? 45:16 Error TypeError: Only abstract or native methods can't have body. */
101/* @@? 47:5 Error SyntaxError: The special predefined method '$_iterator' cannot be asynchronous. */
102/* @@? 47:5 Error SyntaxError: The special predefined method '$_iterator' should not have parameters. */
103/* @@? 47:21 Error TypeError: The return type of '$_iterator' must be a type that implements Iterator interface. */
104/* @@? 47:21 Error TypeError: Return type of async function must be 'Promise'. */
105/* @@? 54:21 Error TypeError: Initializers are not allowed in ambient contexts: x */
106/* @@? 54:23 Error SyntaxError: Initializers are not allowed in ambient contexts. */
107/* @@? 58:9 Error SyntaxError: Unexpected token 'native'. */
108/* @@? 58:16 Error SyntaxError: 'native' flags must be used for functions only at top-level. */
109/* @@? 58:22 Error TypeError: Native and Declare methods should have explicit return type. */
110/* @@? 58:24 Error SyntaxError: Unexpected token, expected '('. */
111/* @@? 58:25 Error SyntaxError: Unexpected token, expected an identifier. */
112/* @@? 58:25 Error SyntaxError: Parameter declaration should have an explicit type annotation. */
113/* @@? 58:25 Error SyntaxError: Unexpected token, expected ',' or ')'. */
114/* @@? 58:25 Error SyntaxError: Unexpected token '}'. */
115/* @@? 61:5 Error SyntaxError: Illegal start of CLASS expression. */
116/* @@? 62:9 Error SyntaxError: Local class or interface declaration members can not have access modifies. */
117/* @@? 65:5 Error SyntaxError: Illegal start of INTERFACE expression. */
118/* @@? 66:9 Error SyntaxError: Local class or interface declaration members can not have access modifies. */
119/* @@? 66:18 Error SyntaxError: Private interface methods must have body. */
120/* @@? 67:9 Error SyntaxError: Unexpected token, expected 'private' or identifier. */
121/* @@? 67:16 Error SyntaxError: Unexpected token, expected 'private' or identifier. */
122/* @@? 67:16 Error SyntaxError: Unexpected token, expected ','. */
123/* @@? 67:16 Error SyntaxError: Identifier expected. */
124/* @@? 67:24 Error SyntaxError: Private interface methods must have body. */
125/* @@? 72:5 Error SyntaxError: Unexpected token, expected 'private' or identifier. */
126/* @@? 72:13 Error SyntaxError: Interface fields must have type annotation. */
127/* @@? 72:14 Error SyntaxError: Invalid Type. */
128/* @@? 74:5 Error SyntaxError: Extension Getter can only have 1 parameter. */
129/* @@? 74:25 Error SyntaxError: Extension Accessor must have a receiver. */
130/* @@? 78:8 Error SyntaxError: Label must be followed by a loop statement. */
131/* @@? 78:8 Error TypeError: Type name 'number' used in the wrong context */
132/* @@? 79:1 Error SyntaxError: Unexpected token '}'. */
133