• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 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'use static'
16
17class A {
18  v: number = 0
19}
20
21let a = A
22
23class B extends a {
24  u: number = 0
25}
26
27class Control {
28    state: number = 0;
29}
30
31interface SelectableControl extends Control {
32    select(): void;
33}
34
35interface C {
36    foo(): void;
37}
38
39class C1 implements C {
40    foo() {}
41}
42
43interface E {
44    foo(): void;
45}
46
47let e = E
48
49class C3 implements e {
50    foo() {}
51}
52
53class C4 implements E {
54    foo() {}
55}
56
57export declare class Bar<T extends Something> {
58    constructor(arg: { new(): T });
59}
60
61function getBaseClass(isAdmin: boolean) {
62  class A{
63    adminMethod() {
64      console.log('这是管理员方法');
65    }
66  }
67  class B{
68    adminMethod() {
69      console.log('这是用户方法');
70    }
71  }
72  if (isAdmin) {
73    return A;
74  } else {
75    return B;
76  }
77}
78
79class User extends getBaseClass(false) {
80  commonMethod() {
81    console.log('这是通用方法');
82  }
83}
84
85class Admin extends getBaseClass(true) {
86  commonMethod() {
87    console.log('这是通用方法');
88  }
89}
90