🐊 Pluggable and configurable JavaScript Linter, code transformer and formatter, drop-in ESLint superpower replacement 💪 with built-in support for js, jsx, typescript, flow, markdown, yaml and json. Write declarative codemods in a simplest possible way 😏
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:
export default class SuperTest extends Test {
protected declare title: string[] // change the type of title from string to string[], because why not?
}
After transformation, it looks like this:
export default class SuperTest extends Test {
protected title: string[] // Error! Can not redeclare an inherited property!
}
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: