mirror of
https://github.com/material-components/material-web.git
synced 2026-03-09 00:09:23 +08:00
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
27 lines
597 B
TypeScript
27 lines
597 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2021 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {customElement} from 'lit/decorators.js';
|
|
|
|
import {styles as sharedStyles} from './lib/shared-styles.css';
|
|
import {TextButton as TextButtonBase} from './lib/text-button';
|
|
import {styles as textStyles} from './lib/text-styles.css';
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
'md-text-button': TextButton;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @soyCompatible
|
|
* @final
|
|
*/
|
|
@customElement('md-text-button')
|
|
export class TextButton extends TextButtonBase {
|
|
static override styles = [sharedStyles, textStyles];
|
|
}
|