Repository navigation
[typescript] fix: satisfy strict mode in typescript (#4683) - #11014
Merged
Merged
Conversation
Fixes the 19 errors `plugins/typescript/typescript` hits once the root tsconfig enables `strict: true`, by typing the shared `BaseTypesVisitor` methods `TsVisitor` overrides instead of patching each override: - visitor-plugin-common: adds `NormalizedDeclarationKindConfig` (`Required<DeclarationKindConfig>`, mirroring `NormalizedOperationDeclarationKindConfig`) for `DEFAULT_DECLARATION_KINDS`, `normalizeDeclarationKind` and `ParsedTypesConfig.declarationKind`, since normalizing always fills every kind (TS2345 on `getPunctuation`). `NamedType` and `ListType` get the param types oldVisit calls them with (`key: string | number | undefined`, `parent: any`, `path: ReadonlyArray<string | number>`, `ancestors: ASTNode[]` to match `getVisitorKindContextFromAncestors`) (TS7006). `ObjectTypeDefinition`, `EnumTypeDefinition` and `DirectiveDefinition` return `string | null`: `TsIntrospectionVisitor` returns `null` from all three to drop types, and the base `EnumTypeDefinition` already returns `null` for external enums (TS2416, TS2322). - typescript: skip document files without a `document` when collecting introspection types (TS2769), type `getMaybeWrapper`/`NamedType`/`ListType` params (TS7006), fall back for the optional `key` in `parent[key]` and for `originalNode.types` (TS2538, TS18048), and `EnumTypeDefinition` returns `string | null` like the introspection override (TS2322). Generated output is unchanged. The strict typecheck goes from 270 to 229 errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UcXG2hnduGFaXB3oCtb8UX eddeee888:oss:issue-fix
…4683) `BaseTypesVisitor`'s `FieldDefinition`, `InputValueDefinition` and `UnionTypeDefinition` now take `key: string | number` and `parent: any`, since oldVisit always passes them. `TsVisitor`'s overrides take them as required too, so `parent[key]` needs no fallback. The strict typecheck goes from 229 to 228 errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UcXG2hnduGFaXB3oCtb8UX
🦋 Changeset detectedLatest commit: 7a0bd0d The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-codegen/visitor-plugin-common |
7.2.8-alpha-20260930110015-7a0bd0df6a5943b59889a6fee5cc1bf3636a1f74 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript-operations |
6.1.10-alpha-20260930110015-7a0bd0df6a5943b59889a6fee5cc1bf3636a1f74 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/typescript |
6.1.1-alpha-20260930110015-7a0bd0df6a5943b59889a6fee5cc1bf3636a1f74 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/client-preset |
6.2.1-alpha-20260930110015-7a0bd0df6a5943b59889a6fee5cc1bf3636a1f74 |
npm ↗︎ unpkg ↗︎ |
@graphql-codegen/plugin-helpers |
7.4.1-alpha-20260930110015-7a0bd0df6a5943b59889a6fee5cc1bf3636a1f74 |
npm ↗︎ unpkg ↗︎ |
eddeee888
commented
Sep 30, 2026
eddeee888
marked this pull request as ready for review
September 30, 2026 13:35
24 of 25 tasks
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of the
strict: truetracker #10985. This fixes the 19 errorsplugins/typescript/typescripthits under strict mode. Instead of patching eachTsVisitoroverride, it types the sharedBaseTypesVisitormethods those overrides extend:visitor-plugin-commonNormalizedDeclarationKindConfig(Required<DeclarationKindConfig>, the same pattern asNormalizedOperationDeclarationKindConfig). It's used byDEFAULT_DECLARATION_KINDS,normalizeDeclarationKindandParsedTypesConfig.declarationKind, because normalizing always sets every kind. This fixes TS2345 ongetPunctuation.NamedType,ListType,FieldDefinition,InputValueDefinitionandUnionTypeDefinition.keyandparentare required, because oldVisit always passes them. This fixes TS7006 and TS2538.ObjectTypeDefinition,EnumTypeDefinitionandDirectiveDefinitioncan returnstring | null.TsIntrospectionVisitorreturnsnullfrom all three to leave types out, and the baseEnumTypeDefinitionalready returnsnullfor external enums. This fixes TS2416 and TS2322.typescriptdocumentwhen collecting introspection types (TS2769).TsVisitorvisitor params.|| []fallback fororiginalNode.types(TS18048).Generated output is unchanged. The strict typecheck goes from 270 to 228 errors: 0 in
typescript, andvisitor-plugin-commondrops from 196 to 173.This is option 3 of the three options discussed (the other two were "fix it inside the package only" and "only add the shared
declarationKindtype"). We picked it so the base visitor signatures get fixed properly now instead of being worked around in each subclass.Related #4683
Type of change
How Has This Been Tested?
tsc --noEmit -p tsconfig.jsonwith the tracker's stricttsconfig.json: 0 errors underplugins/typescript/typescript, and no new errors in other packages.pnpm types:check(the current non-strict config) is clean.vitest --project typescript --project typescript-operations --project typescript-resolvers: 530 passed, 2 skipped.🤖 Generated with Claude Code
https://claude.ai/code/session_01UcXG2hnduGFaXB3oCtb8UX
Generated by Claude Code