Skip to content

.find returning type any when using useRepo #1863

@Kieran-DK

Description

@Kieran-DK

Environment

Vue 3 (not Nuxt) + TypeScript

Reproduction

import { Model, Repository } from "pinia-orm";

export class MyItem extends Model {
  declare id: number;

  ...
}

export class MyItemRepo extends Repository<MyItem> {
  use = MyItem;

  ...
}
import { useRepo } from "pinia-orm";

const myItemRepo = useRepo(MyItemRepo);
const myItem = myItemRepo.find(1); // Type of `myItem` is `any`, not `MyItem | undefined`.

Describe the bug

When using useRepo to get a repository instance, when calling the find method, the type of the returned value is any, not the type of the Model as you would expect.

This may have been caused by the removal of .find from the Repository class: https://github.com/CodeDredd/pinia-orm/pull/1831/files#diff-de773c674180b12ca839cbf77f65443d6964b83ad45e8615e727e76601c7330fL340-L348

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions