Skip to content
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

[printer] Removes any declare of class properties. #175

Closed
ElPrudi opened this issue Jul 27, 2023 · 2 comments
Closed

[printer] Removes any declare of class properties. #175

ElPrudi opened this issue Jul 27, 2023 · 2 comments
Labels

Comments

@ElPrudi
Copy link

ElPrudi commented Jul 27, 2023

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!
}
@coderaiser
Copy link
Owner

TypeScript has so many abilities 😀... Just fixed 🎈! Is it works for you?

@ElPrudi
Copy link
Author

ElPrudi commented Jul 28, 2023

It doesn't try to change it anymore. Thank you very much :)

@ElPrudi ElPrudi closed this as completed Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants