Skip to content

Conversation

@max-kahnt-keylight
Copy link
Contributor

import * as O from 'objection';

export const TestMixin = <M extends O.ModelClass<O.Model>>(Model: M) =>
  class extends Model {
    additionalProperty: string;

    static get modifiers() {
      return {
        ...super.modifiers,
        additionalModifier: <QB extends O.QueryBuilder<O.Model>>(qb: QB) => qb.where({ id: 0 }),
      };
    }
  };

fails with error
error TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'. for Typescript 4.8.4.

With this fix, it compiles successfully.
This also resolves #625 for me.

@lehni
Copy link
Collaborator

lehni commented Apr 17, 2023

Perfect, let's merge it!

@lehni
Copy link
Collaborator

lehni commented Oct 5, 2023

@max-kahnt-keylight there are issues with your fix, see #2531. Could you help out with solving them? I will have to revert this change for the next release otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discussion: TypeScript plugin/mixin woes

2 participants