Skip to content

Missing types for _count when used inside includeΒ #570

@Azzerty23

Description

@Azzerty23

Repro : https://stackblitz.com/~/github.com/Azzerty23/v3-doc-orm/tree/Azzerty23/zen-count-in-include?file=find/selection.ts

npm run find:selection

Here :

// ...
const countInInclude = await db.user.findFirst({
  include: {
    posts: {select: { title: true }},
    _count: {select: {posts: true}}
  }
})
console.log("countInInclude", countInInclude)
// @ts-expect-error
console.log(countInInclude?._count) // <- typing issue
Image

Works at runtime as expected :

// ...
countInInclude {
  id: 1,
  email: 'u1@test.com',
  profile: null,
  posts: [ { title: 'Post1' } ],
  _count: { posts: 1 }
}
1

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