Skip to content

Abstract Members Not Properly Validated in Multiple Mixin CompositionΒ #62014

Closed as not planned
@piotrjoniec

Description

@piotrjoniec

πŸ”Ž Search Terms

abstract getters members methods mixin

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250707#code/C4TwDgpgBAwg9gOwM7AE4FcDGw6qgXigQgHcoAKAOmoENUBzJALihoRAG0BdASgID4oAbwC+AbgBQEgGboE2AJaIoAWQUAPBQgCCAHgAqUCOuAQEAEySxEKDNlz9yAIxpIILfXyESorJ7ZpsKEwAG1crNU0EIxMzSygXN2EfXz8AoNMUFQhgAAs4c3IeFlsteklfESlfVBz0VGjIrUkqmTlFZSaEACEDGNMLK3hkNCwcVEdE9yhPZN8afzRA4GCwpAiNLX64qym51IX0lczgbLyCopK0MoqoVpq6htVNhBapUPCobtdoUSkAen+UAAcnAjKhULgoLUwLhTOYCFAAGLaACSABkJB91lBUQBbMAhCB4szAGjAJQ9baDZ5RbrkLracjfNw8LxSVqAqAAUQhUMIAHkANISLmghAAWkOSyC2KsAHJ8YTiaTyZTtPKoOY4BArAg4CsFASiSSEIaELkIKgFPC0jKViS8U4rVATmd8gjpJC8atPvLGbpQJA4NIvj9+JQulAAGRhtzyyjkABMAFYAIwpnhYtZWJUm1UUxDaanxRnMn7siQiIA

πŸ’» Code

type Constructor = new (...args: any[]) => {};

function MixinA<T extends Constructor>(base: T) {
  abstract class Mixin extends base {
    abstract testMethod(): string;
  }

  return Mixin;
}

function MixinB<T extends Constructor>(base: T) {
  abstract class Mixin extends base {
    abstract testMethod(): string;
  }

  return Mixin;
}

class Base {}

// No error reported = FAIL
class ImplementationB extends MixinB(MixinA(Base)) {

}

// Error = OK
// Non-abstract class 'ImplementationA' does not implement inherited abstract member testMethod from class 'MixinA<typeof Base>.Mixin & Base'.(2515)
class ImplementationA extends MixinA(Base) {

}

πŸ™ Actual behavior

There was no error reported for ImplementationB

TypeScript fails to detect unimplemented abstract members when multiple mixins are composed together, even when those mixins declare the same abstract member.

πŸ™‚ Expected behavior

An error should be reported since ImplementationB did not implement the abstract method testMethod from MixinA and MixinB.

TypeScript should report an error when a concrete class extends multiple mixins that declare abstract members, and those abstract members are not implemented in the concrete class.

Additional information about the issue

TypeScript fails to detect unimplemented abstract members when multiple mixins are composed together, even when those mixins declare the same abstract member.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions