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 16declare function print(str:any):string; 17 18class A { 19 name:string; 20 value:number; 21 constructor(name:string, value:number) { 22 this.name = name; 23 this.value = value; 24 } 25} 26class B extends A{ 27 constructor(...b: ConstructorParameters<typeof A>) { 28 super(...b); 29 } 30} 31 32var obj = new B("AOT", 123); 33print(obj.name); 34print(obj.value); 35 36class Demo { 37 constructor(x, y) { 38 this.x = x; 39 this.y = y; 40 } 41 aboutToDo(){ 42 this.x = 0; 43 this.y = 0; 44 } 45} 46 47class Demo2 extends Demo{ 48aboutToDo(){ 49 super.aboutToDo(); 50} 51} 52 53let d = new Demo2('hello', 'bye'); 54print(d.x); 55d.aboutToDo(); 56print(d.x); 57