1/* 2 * Copyright (c) 2023 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 description: > 17 adds the override keyword.provides a new noImplicitOverride flag.When this option is turned on, it becomes an error to override any method from a superclass unless you explicitly use an override keyword. 18 In that last example, TypeScript would error under noImplicitOverride, and give us a clue that we probably need to rename our method inside of Derived. 19 And index signatures can now be declared as static. 20 module: ESNext 21 isCurrent: true 22 ---*/ 23 24 25import { Assert } from "../../../suite/assert.js" 26 27class Boss { 28 run(person?: string): string { 29 return person + " go" 30 } 31} 32class Manage extends Boss { 33 run(person?: string): string { 34 return super.run(person); 35 } 36} 37class Staff extends Boss { 38 override run(person?: string): string { 39 super.run(); 40 return person + " run"; 41 } 42} 43let boss = new Boss(); 44Assert.equal(boss.run("boss"), "boss go"); 45 46let manage = new Manage(); 47Assert.equal(manage.run("manage"), "manage go"); 48 49let staff = new Staff(); 50Assert.equal(staff.run("staff"), "staff run"); 51