With typescript, when defining classes with inheritance, is it possible to overload a protected constant ?
Exemple :
class A {
static defaultProps = {
message: ''
}
}
class B extends A {
static defaultProps = {
// get defaultProps from A,
title: ''
}
}
I don't know if it's important that I'm working with React.
You should just extend the defaultProps
prop from A
class (note: the defaultProps
is ˙static` so you can access that on the class not on the instance)
The following should work:
class A {
static defaultProps = {
message: ''
}
}
class B extends A {
static defaultProps = {
...A.defaultProps,
title: ''
}
}