MichalLytek / MichalLytek/typegraphql-prisma

TS compilation fails with noUncheckedIndexedAccess set to true

Open
#486 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
918
Forks
130
PR merge metrics
No merged PRs in 30d

Description

**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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with generated/type-graphql/helpers.ts at line 27 and reproduce the failure using noUncheckedIndexedAccess in tsconfig.json with a custom generator output. Verify the generated helpers.ts compiles successfully under the reported TypeScript setup without the TS2488 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.