Skip to content

can't use InferSelectModel within Pick/Promise functions #drizzle #1900

Open
@MaxZelinka

Description

@MaxZelinka

Hi, we have just tried to create a type (from the database table) using drizzle, which we have defined as an endpoint.
This can be used as a simple variable, but not within a promise statement.

type test = Pick<InferSelectModel<typeof users>, "id" | "entity_id">;

  async (): Promise<test> => { <-- doesn't work
    const t: test = { <-- work
      id: 1,
      entity_id: 1,
    };

also got the errors if I try to run encore:

import { InferSelectModel } from "drizzle-orm";
   |          ^^^^^^^^^^^^^^^^
error: unknown identifier

type test = Pick<InferSelectModel<typeof users>, "id" | "entity_id">;
    |                  ^^^^^^^^^^^^^^^^

error: unsupported indexed access type operation: obj Basic(
    Never,
) index Literal(
    String(
        "id",
    ),
)

error: unsupported indexed access type operation: obj Basic(
    Never,
) index Literal(
    String(
        "entity_id",
    ),
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions