Skip to content

[fragment-matcher] fix: satisfy strict mode in fragment-matcher (#4683) - #11012

Merged
eddeee888 merged 2 commits into
masterfrom
claude/nifty-ptolemy-bfkymv
Sep 30, 2026
Merged

eddeee888 merged 2 commits into
masterfrom
claude/nifty-ptolemy-bfkymv

Conversation

@eddeee888

Copy link
Copy Markdown
Collaborator

Description

This fixes the 13 strict: true type errors in @graphql-codegen/fragment-matcher, as part of the strict-mode checklist in #10985. All changes are in packages/plugins/other/fragment-matcher/src/index.ts and are types only:

  • TS18048 / TS2345: PluginFunction declares the 4th parameter info as optional, so info.outputFile fails under strictNullChecks. The plugin now reads info?.outputFile.
  • TS7006 (6): the introspection result was cast as any, which left the filter, sort and reduce callbacks untyped. It's now typed as ExecutionResult<IntrospectionResultData> (cast through unknown, because graphql's ObjMap result doesn't overlap an interface without an index signature). createPossibleTypesCollection has typed params and a return type. possibleTypes is non-null-asserted there because unions and interfaces always have it.
  • TS2454 (5): in the TS output path, typename and type are only assigned when apolloClientVersion is 2 or 3. They're now typed string | undefined.

Generated output doesn't change, so there's no changeset, matching #10988 and #10989. The TS path still prints undefined when apolloClientVersion is neither 2 nor 3, while the JSON/JS paths treat any value other than 2 as v3. That bug stays as it is, because this PR keeps to type-only fixes.

Related #4683

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • pnpm exec tsc --noEmit passes with the current master tsconfig.
  • With the strict tsconfig from chore: enable strict: true in root tsconfig (#4683) #10985, tsc --noEmit now reports 0 errors under packages/plugins/other/fragment-matcher (it was 13). The total goes from 283 to 270.
  • pnpm exec vitest run packages/plugins/other/fragment-matcher: 14/14 pass.

Further comments

Once this merges, tick plugins/other/fragment-matcher in the #10985 checklist.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MzUSkE6kGAfWan8VDUSkNt


Generated by Claude Code

Fixes the 13 errors `plugins/other/fragment-matcher` hits once the root
tsconfig enables `strict: true`, with types-only changes:

- read the optional plugin `info` argument as `info?.outputFile` (TS18048,
  TS2345)
- type the introspection result as `ExecutionResult<IntrospectionResultData>`
  and annotate `createPossibleTypesCollection`, so the filter/sort/reduce
  callbacks are no longer implicit `any` (TS7006)
- type `typename` and `type` as `string | undefined`, since they are only
  assigned for `apolloClientVersion` 2 or 3 (TS2454)

Generated output is unchanged. The strict typecheck goes from 283 to 270
errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzUSkE6kGAfWan8VDUSkNt

eddeee888:oss:issue-fix
@changeset-bot

changeset-bot Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8acae53

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/visitor-plugin-common 7.2.8-alpha-20260930103212-8acae536966e3b61933a088b608dafd579610d8a npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 6.1.10-alpha-20260930103212-8acae536966e3b61933a088b608dafd579610d8a npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 6.2.1-alpha-20260930103212-8acae536966e3b61933a088b608dafd579610d8a npm ↗︎ unpkg ↗︎
@graphql-codegen/plugin-helpers 7.4.1-alpha-20260930103212-8acae536966e3b61933a088b608dafd579610d8a npm ↗︎ unpkg ↗︎

@eddeee888
eddeee888 marked this pull request as ready for review September 30, 2026 10:43
@eddeee888
eddeee888 merged commit ad49090 into master Sep 30, 2026
22 checks passed
@eddeee888
eddeee888 deleted the claude/nifty-ptolemy-bfkymv branch September 30, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants