Skip to content

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

@DarkOutX

Description

@DarkOutX

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions