-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Support 'static' to be used with 'abstract' and generic type #10603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is more general than the generic type use case: abstract class Base {
abstract foo: string
static bar: string
}
class BaseExtended extends Base {
foo = '1'
// expected error because static property is missing, but got none
// static bar = '1'
} For context, I want this feature so I can properly type the static properties on my React class components. The React typings on DefinitelyTyped define a // error as expected, displayName should be string
const ReactComponent: ComponentClass<any> = class extends Component<any, any> {
static displayName = 1
render() {
return <div>{this.props.name}</div>
}
}; If we had the feature requested here, we could consolidate the |
looks like a duplicate of #14600 |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
TypeScript Version: 2.0.0
Code
Expected behavior:
Can define static member in abstract class, so that force child classes contains it.
Such as
defaultProps
inReact.Component
Actual behavior:
Neither interface nor abstract class can achieve this.
The text was updated successfully, but these errors were encountered: