Skip to content

TS compilation fails with noUncheckedIndexedAccess set to true #486

@aracheli-fae

Description

@aracheli-fae

Describe the Bug
Generated file helpers.ts in invalid for TypeScript setups with "noUncheckedIndexedAccess": true in their tsconfig.json.
This is an issue if the code is generated outside of node_modules, for example with the config:

generator typegraphql {
  provider        = "typegraphql-prisma"
  output          = "../generated/type-graphql"
}

The issue is due to an unchecked index access:

generated/type-graphql/helpers.ts:27:22 - error TS2488: Type '[string, any] | undefined' must have a '[Symbol.iterator]()' method that returns an iterator.

27               const [[key, { value }]] = Object.entries(argument);

To Reproduce

  • Add "noUncheckedIndexedAccess": true to your tsconfig.json
  • Add a custom output to your generator config

Expected Behavior
TS should be able to compile correctly

Environment (please complete the following information):

  • OS: MacOS 15.6.1
  • Node 22.18.0
  • typegraphql-prisma 0.28.0
  • Prisma version 5.22.0
  • TypeScript version 5.9.2

Additional Context
Opening a PR to solve this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions