![](/img/trans.png)
[英]How to define a nonserializable property for TypeScript `class` or `interface`?
[英]How to exclude interface property from extended class in typescript
我有两节课
interface IBasicFunctionalityProps {
propertySpecificForBasicFunctionality: MyType;
propertyNotSpecificForBasicFunctionality: boolean;
}
class BasicFunctionalityClass extends React.Component<IBasicFunctionalityProps> {...}
class ExtendedFunctionalityClass extends BasicFunctionalityClass
BasicFunctionality
有两个道具,没关系。 但是在继承的类ExtendedFunctionalityClass
我不想具有propertySpecificForBasicFunctionality
属性。 我如何可以忽略此属性?
这完全违背了继承的概念。
我认为您应该将IBasicFunctionalityProps
接口拆分为两个单独的接口,并根据需要实现它们。 这样,您就可以实现所需的行为。
无论如何,React使用继承劝阻。 https://reactjs.org/docs/composition-vs-inheritance.html#so-what-about-inheritance
最好的祝福
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.