Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find** methods with { raw: true } should has another types? #192

Open
DarkOutX opened this issue Jun 8, 2023 · 0 comments
Open

find** methods with { raw: true } should has another types? #192

DarkOutX opened this issue Jun 8, 2023 · 0 comments

Comments

@DarkOutX
Copy link

DarkOutX commented Jun 8, 2023

Hello. Maybe I don't undestand something, but if I will use ModelStatic methods find*** with options { raw: true }, I get type errors

Example:

const item = await this._model.findOne( { where: { id }, raw: true } );

item should has TModelAttributes type, however it has type Model and looks like it requires call item.get() to receive object

We can find used types is types/model.d.ts where the ReturnValue is fixed M extending Model

  public static findOne<M extends Model>(
      this: ModelStatic<M>,
      options: NonNullFindOptions<Attributes<M>>
  ): Promise<M>;

It works fine for me after adding overloads like this:

  public static findOne<M extends Model>(
      this: ModelStatic<M>,
      options: NonNullFindOptions<Attributes<M>> & { raw: true }
  ): Promise<Attributes<M>>;

So, please, describe, am I doing something wrong? I guess a lot of people use this repo, and a lot of them using raw, but nobody meets the same problem? 0_o

@DarkOutX DarkOutX changed the title find** methods with { raw: true } should has another typings? find** methods with { raw: true } should has another types? Jun 24, 2024
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

No branches or pull requests

1 participant