Skip to content

Merging Classes With Getters Converts Into a Property #61967

Closed
@LukeAbby

Description

@LukeAbby

🔎 Search Terms

Mixin class, getter merging, property, is defined as a property in class but is overridden here in 'Test' as an accessor.

🕗 Version & Regression Information

  • This changed in commit or PR 3ffe253

However, given that the title of this commit is "Always error when property overrides accessor or vice versa" I would say this issue likely originated earlier but was not reported.

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.8.3#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwCMoBnLMAWSwA8tUAeAFXhCoxFWGPhwICtwMAGngBVZq3adufAQD4AFBgBc8BsOQqRAShVMAZKIDcAKGOhIsBBeJcA4iAxsYAQXgBvY-C9g8xDDGRMHBh5ADpw2ABzYhUoVABPAG0AXS1TL3hIh3haAGEcAFsAB0ksZAL5HUIcHAgQOJMAX1NzaDh4azsHJwAhd09vX39AjGCwiJho2ISUtIHM7LzCko4yiqqCGrq442azcDaraBtVED8+ljYOLiJSCmpaeXtHEBdhZ96tfoycADdXmBYUALDA5VD5YqlcqVFSbWr1VAmDIAemRGXR6IAevAAORLSGrco4nJcUCIWggYDwEjU+BFGA4EowDDxMEdY5cHEfV6uAzcmA9HHCAjIUFYLh-AFA0D4AAWrwQtFxDDOGEF1K4cWpYDAZ2IwVCuyAA

💻 Code

declare function basicMixin<T extends object, U extends object>(t: T, u: U): T & U;

declare class GetterA {
   constructor(...args: any[])

   get inCompendium(): boolean;
}

declare class GetterB {
   constructor(...args: any[])

   get inCompendium(): boolean
}

declare class TestB extends basicMixin(GetterA, GetterB) {
   override get inCompendium(): boolean;
   //           ^ 'inCompendium' is defined as a property in class 'GetterA & GetterB', but is overridden here in 'TestB' as an accessor.
}

🙁 Actual behavior

The error 'inCompendium' is defined as a property in class 'GetterA & GetterB', but is overridden here in 'TestB' as an accessor. due to get inCompendium(): boolean being converted to inCompendium: boolean when computing GetterA & GetterB

🙂 Expected behavior

No error.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fix AvailableA PR has been opened for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions