1/* 2 * Copyright (c) 2022 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 16 17const computed1: unique symbol = Symbol("symbol1"); 18 19class Base { 20 prop = "base_prop"; 21 prop1 = "base_prop1"; 22 prop2 = "base_prop2"; 23 "str_prop" = "base_str_prop"; 24 1 = "base_1"; 25 [computed1] = "base_computed1"; 26 static "s_str_prop" = "base_static_str_prop"; 27} 28 29class A extends Base { 30 "str_prop" = "A_str_prop"; 31 [computed1] = "A_computed1"; 32 static "s_str_prop" = "A_s_str"; 33} 34 35class B extends Base { 36 prop:string; 37 constructor() { 38 super(); 39 this.prop = "ctor_B_prop"; 40 this.prop1 = "ctor_B_prop1"; 41 this["str_prop"] = "B_ctor_str_prop"; 42 } 43 prop1 = "B_prop1"; 44 "str_prop" = "B_str"; 45} 46 47class C extends Base { 48 constructor(public prop = "tsparam_prop") { 49 super(); 50 this[computed1] = "C_computed1"; 51 } 52} 53 54var objA = new A(); 55print(objA["str_prop"]); 56print(objA[computed1]); 57print(A["s_str_prop"]); 58 59var objB = new B(); 60print(objB.prop); 61print(objB.prop1); 62print(objB.prop2); 63print(objB["str_prop"]); 64 65var objC = new C(); 66print(objC.prop); 67print(objC[computed1]); 68