We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
setter without getter abstract class
overriding a setter on a base class causes the subclass getter to return undefined
The getter not functioning properly when overriding the setter.
Tested on v3, v4, and v5.
https://www.typescriptlang.org/play?ts=5.2.2#code/FASwdgLgpgTgZgQwMZQAQAUYHsAmBXJCAZQgWlQG9hVUQcAuVAZwhnAHMBua1MBAWyiMWbMFx4syeJsNYduAX2DAEAIxHIIqJABsETJhmz5CAHiKooAD2hgchzLgLFS5ALxGnhEmSgA+Sh4kLDARZywYAAoAB2xoQigcVAASSWhGIgBKQJolHnYoLTpI7KoaGhhCvBgwVAgACxAmADpU1yhmuh4lGgKtNOkSnPLKiGrahqbWtI6Bpm5c5RomQuZXQYA3BB08ITXRdlKeGkmWtt9mudQPLZ2oBdQlPPBoeGQ0ACEsLABrH3JrLZ7J4TC5fMM+IJZAcHk1VGBofJgHldPpDF9fpYbFA7A5jM5TBi-u0AmVmKs5pFbrtEWIjuVtCEmFgdB0dFh2JEAERELCCZh0KAAWigcDgUEIqHqsA6XMyDxOjTOM0u60MN22uweT2UwVCWlU3x+114UAA7qgiZEKLwBHsuQAVKAsLkAGjWUhkqC5AEFCCANlA3bQGN6AIzBuEI8MAJgAzFzHvLgHrmazmuzOYbfqrPfKgA
interface ProductState { id: string; name: string; status: string; } abstract class Product<S extends ProductState = ProductState> { constructor(protected $state: S) { } get id() { return this.$state.id } get status() { return this.$state.status; } set status(value: string) { this.$state.status = value; } } interface BookState extends ProductState { name: string; isbn: string; } class Book extends Product<BookState> { set status(value: string) { console.log("Some side-effect here."); this.$state.status = value; } } const book = new Book({ name: "Test", status: "Active", id: "1", isbn: "123" }); // Returns undefined console.log(book.status);
the field status returns undefined.
status
the field status returns "Active".
No response
The text was updated successfully, but these errors were encountered:
Duplicate of #47581. Used search terms: getter setter in:title
getter setter in:title
Sorry, something went wrong.
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
No branches or pull requests
🔎 Search Terms
setter without getter abstract class
overriding a setter on a base class causes the subclass getter to return undefined
The getter not functioning properly when overriding the setter.
🕗 Version & Regression Information
Tested on v3, v4, and v5.
The getter not functioning properly when overriding the setter.
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.2.2#code/FASwdgLgpgTgZgQwMZQAQAUYHsAmBXJCAZQgWlQG9hVUQcAuVAZwhnAHMBua1MBAWyiMWbMFx4syeJsNYduAX2DAEAIxHIIqJABsETJhmz5CAHiKooAD2hgchzLgLFS5ALxGnhEmSgA+Sh4kLDARZywYAAoAB2xoQigcVAASSWhGIgBKQJolHnYoLTpI7KoaGhhCvBgwVAgACxAmADpU1yhmuh4lGgKtNOkSnPLKiGrahqbWtI6Bpm5c5RomQuZXQYA3BB08ITXRdlKeGkmWtt9mudQPLZ2oBdQlPPBoeGQ0ACEsLABrH3JrLZ7J4TC5fMM+IJZAcHk1VGBofJgHldPpDF9fpYbFA7A5jM5TBi-u0AmVmKs5pFbrtEWIjuVtCEmFgdB0dFh2JEAERELCCZh0KAAWigcDgUEIqHqsA6XMyDxOjTOM0u60MN22uweT2UwVCWlU3x+114UAA7qgiZEKLwBHsuQAVKAsLkAGjWUhkqC5AEFCCANlA3bQGN6AIzBuEI8MAJgAzFzHvLgHrmazmuzOYbfqrPfKgA
💻 Code
🙁 Actual behavior
the field
status
returns undefined.🙂 Expected behavior
the field
status
returns "Active".Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: