Repository navigation
[fragment-matcher] fix: satisfy strict mode in fragment-matcher (#4683) - #11012
Merged
Merged
Conversation
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
|
Contributor
🚀 Snapshot Release (
|
| 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 ↗︎ |
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
This fixes the 13
strict: truetype errors in@graphql-codegen/fragment-matcher, as part of the strict-mode checklist in #10985. All changes are inpackages/plugins/other/fragment-matcher/src/index.tsand are types only:PluginFunctiondeclares the 4th parameterinfoas optional, soinfo.outputFilefails understrictNullChecks. The plugin now readsinfo?.outputFile.as any, which left the filter, sort and reduce callbacks untyped. It's now typed asExecutionResult<IntrospectionResultData>(cast throughunknown, because graphql'sObjMapresult doesn't overlap an interface without an index signature).createPossibleTypesCollectionhas typed params and a return type.possibleTypesis non-null-asserted there because unions and interfaces always have it.typenameandtypeare only assigned whenapolloClientVersionis 2 or 3. They're now typedstring | undefined.Generated output doesn't change, so there's no changeset, matching #10988 and #10989. The TS path still prints
undefinedwhenapolloClientVersionis 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
How Has This Been Tested?
pnpm exec tsc --noEmitpasses with the currentmastertsconfig.strict: truein root tsconfig (#4683) #10985,tsc --noEmitnow reports 0 errors underpackages/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-matcherin the #10985 checklist.🤖 Generated with Claude Code
https://claude.ai/code/session_01MzUSkE6kGAfWan8VDUSkNt
Generated by Claude Code