You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to do more complex polymorphism in TypeScript, there's a problem when it comes to instance properties: you can't change their inherited type. But if the subclasses fully manage this type and it mostly completely overlaps with the type of the properties in the parent class, TypeScript lets you declare the type again:
exportdefaultclassSuperTestextendsTest{protecteddeclaretitle: string[]// change the type of title from string to string[], because why not?}
After transformation, it looks like this:
exportdefaultclassSuperTestextendsTest{protectedtitle: string[]// Error! Can not redeclare an inherited property!}
The text was updated successfully, but these errors were encountered:
If you want to do more complex polymorphism in TypeScript, there's a problem when it comes to instance properties: you can't change their inherited type. But if the subclasses fully manage this type and it mostly completely overlaps with the type of the properties in the parent class, TypeScript lets you
declare
the type again:After transformation, it looks like this:
The text was updated successfully, but these errors were encountered: