CodeDredd / pinia-orm

The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.
https://pinia-orm.codedredd.de/
MIT License
444 stars 38 forks source link

Repository typings are broken #1847

Closed daniser closed 4 months ago

daniser commented 4 months ago

Environment

playground

Reproduction

https://stackblitz.com/edit/github-t5neyu

Describe the bug

Problem appeared since version 1.9.0 when using decorators. 1.7.2 worked fine.

Additional context

No response

Logs

pages/index.vue:8:26 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(repository: Repository<Model> | Constructor<Repository<Model>>, pinia?: Pinia | undefined): Repository<Model>', gave the following error.
    Argument of type 'typeof UserRepository' is not assignable to parameter of type 'Repository<Model> | Constructor<Repository<Model>>'.
      Type 'typeof UserRepository' is not assignable to type 'Constructor<Repository<Model>>'.
        Construct signature return types 'UserRepository' and 'Repository<Model>' are incompatible.
          The types of 'query().wheres' are incompatible between these types.
            Type 'Where<User>[]' is not assignable to type 'Where<Model>[]'.
              Type 'Where<User>' is not assignable to type 'Where<Model>'.
                Types of property 'field' are incompatible.
                  Type 'string | string[] | WherePrimaryClosure<User> | undefined' is not assignable to type 'string | string[] | WherePrimaryClosure<Model> | undefined'.
                    Type 'WherePrimaryClosure<User>' is not assignable to type 'string | string[] | WherePrimaryClosure<Model> | undefined'.
                      Type 'WherePrimaryClosure<User>' is not assignable to type 'WherePrimaryClosure<Model>'.
                        Type 'Model' is not assignable to type 'User'.
  Overload 2 of 2, '(model: Constructor<Model>, pinia?: Pinia | undefined): Repository<Model>', gave the following error.
    Argument of type 'typeof UserRepository' is not assignable to parameter of type 'Constructor<Model>'.
      Type 'UserRepository' is missing the following properties from type 'Model': _meta, $entity, $config, $namespace, and 39 more.

8 const userRepo = useRepo(UserRepository);
                           ~~~~~~~~~~~~~~