Skip to content

Type export from client instead of model #2243

@mjperlini

Description

@mjperlini

Description and expected behavior
In the latest version, I have found issues with the generated types and the typing of the returned data from the generated Tanstack Query hooks. With the earlier versions, I imported types from the generated models directory:

import type { Routine } from "../generated/zenstack/models";

Something changed, and I needed to import the type as 'RoutineModel'. I also found that all of my hooks returned { data } types as any, which caused many typescript errors.

Investigating, I have found that if I import the type from the client library, it works as before:

import type { Routine } from "../generated/zenstack/client";

I also need to make the change in the generated hooks file to have the returned data properly typed:

from
import type { Prisma, Routine } from "../zenstack/models";

to
import type { Prisma, Routine } from "../zenstack/client";

I do not know which version this started happening, I need to use Prisma 6.14 for other reasons, so can't regress to an earlier version.

Environment:

  • ZenStack version: [2.18.1 / 2.19.0]
  • Prisma version: [6.14.0 / 6.16.1]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions