graphql-code-generator: Property 'enter' does not exist on type '{ readonly enter?: ASTVisitFn ...
Describe the bug
Getting the following build errors with TS:
node_modules/@graphql-codegen/plugin-helpers/oldVisit.d.ts:5:75 - error TS2339: Property 'enter' does not exist on type '{ readonly enter?: ASTVisitFn<NameNode> | undefined; readonly leave: ASTReducerFn<NameNode, unknown>; } | { readonly enter?: ASTVisitFn<DocumentNode> | undefined; readonly leave: ASTReducerFn<...>; } | ... 41 more ... | undefined'.
5 enter?: Partial<Record<keyof NewVisitor, NewVisitor[keyof NewVisitor]['enter']>>;
~~~~~~~
node_modules/@graphql-codegen/plugin-helpers/oldVisit.d.ts:6:75 - error TS2339: Property 'leave' does not exist on type '{ readonly enter?: ASTVisitFn<NameNode> | undefined; readonly leave: ASTReducerFn<NameNode, unknown>; } | { readonly enter?: ASTVisitFn<DocumentNode> | undefined; readonly leave: ASTReducerFn<...>; } | ... 41 more ... | undefined'.
6 leave?: Partial<Record<keyof NewVisitor, NewVisitor[keyof NewVisitor]['leave']>>;
To Reproduce
Use together:
"@graphql-codegen/plugin-helpers": "^2.4.1",
"graphql": "^16.3.0"
Then just importing it will trigger the bug:
import type { Types } from '@graphql-codegen/plugin-helpers';
- My GraphQL schema:
N/A
- My GraphQL operations:
N/A
- My
codegen.ymlconfig file:
N/A
Expected behavior
Not produce build errors.
Environment:
- OS: macOS
@graphql-codegen/plugin-helpers: 2.4.1- NodeJS: v14.17.6
Additional context
N/A
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 16 (2 by maintainers)
Commits related to this issue
- Fix TS type error on strictNullChecks: true `Partial<T>` includes `{}`, therefore `NewVisitor[keyof NewVisitor]` includes `undefined`, and indexing `undefined` is error. Issue: https://github.com/... — committed to dittos/graphql-code-generator by dittos 2 years ago
- Fix TS type error on strictNullChecks: true `Partial<T>` includes `{}`, therefore `NewVisitor[keyof NewVisitor]` includes `undefined`, and indexing `undefined` is error. Issue: https://github.com/do... — committed to dittos/graphql-code-generator by dittos 2 years ago
- fix: TS type error on `strictNullChecks: true (#7931) `Partial<T>` includes `{}`, therefore `NewVisitor[keyof NewVisitor]` includes `undefined`, and indexing `undefined` is error. Issue: https://g... — committed to dotansimha/graphql-code-generator by dittos 2 years ago
Weird, nuked
node_modules, and re-installed. Fixed the problem. 🤷🏼Will do, if I can repro the issue again.
Good question.
Seems like no?