Material Web Team 0f6d402472 Add the override keyword to class members in TypeScript files
TypeScript’s override keyword (added in 4.3) works similarly to @Override in Java. It makes the intention clear and ensures there is actually a member in the base class with the same name. This helps with things like:
- Typos in the overriding member name
- Remember to rename members in sub classes when renaming an overridden member in a base class

class Parent {
  foo() {}
}

class Child extends Parent {
  override bar() {}
  //       ~~~ This member cannot have an 'override' modifier because it is not declared in the base class 'Parent'.
}

This change will not cause a runtime change: the override keyword is not present in the resulting JavaScript.

PiperOrigin-RevId: 399452347
2021-09-28 09:00:31 -07:00

23 lines
424 B
TypeScript

/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import {customElement} from 'lit/decorators.js';
import {styles} from './lib/switch-styles.css.js'
import {Switch} from './lib/switch.js';
declare global {
interface HTMLElementTagNameMap {
'md-switch': MDSwitch;
}
}
@customElement('md-switch')
export class MDSwitch extends Switch {
static override styles = [styles];
}