Eliminate all 11 source any with real Linear GraphQL and SDK context types - #48
Conversation
…K context types Mirror the pm-github PR #18 precedent. Two clusters: (A) Linear GraphQL responses: LinearResponse is now a generic envelope LinearResponse<TData> carrying data?: TData and errors?: LinearGraphQLError[], and linearRequest/linearRequestOnce take a type parameter so each call site gets a typed response with no cast. Per-operation data types declare only the fields actually read: LinearIssuesData (paginated issues query), LinearTeamData/LinearTeamNode (TEAM_QUERY team resolution), LinearViewerData (viewer{id} credential probe). The issueCreate/issueUpdate mutation sites consume only the error envelope, so they are typed linearRequest<unknown> rather than mirroring an unread schema. The JSON.parse wire boundary keeps its single deserialization cast, now as LinearResponse<TData>. (B) SDK handler/context types: isJsonMode and renderImportDryRun take CommandHandlerContext | ImportExportContext, and the registerPreflight callback takes PreflightOverrideContext, all imported type-only from @unbrained/pm-cli/sdk/authoring (same subpath as the existing ExtensionApi imports, so no runtime module edge). --json continues to be read from ctx.global.json per the SDK contract; defensive ?. chains are retained. Behaviour is unchanged. Gates: build, npm test (63 pass), tsc --noEmit, changelog:check, and a zero-any grep all pass; real activation proof in a throwaway workspace shows pm linear --help, sync/validate, JSON mode, and the offline dry-run all working with host commands intact. pm-item: pm-linear-pfmo
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
WalkthroughThis refactor adds generic Linear GraphQL response types, types operation-specific payloads, replaces remaining handler and context ChangesLinear typing refactor
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideRefactors the Linear GraphQL client and SDK integration in index.ts to eliminate remaining any usages by introducing typed GraphQL response envelopes, per-operation data types, and concrete SDK context types, while keeping runtime behavior unchanged and recording the work in pm agent metadata files. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Greptile SummaryThis PR removes the remaining explicit
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| index.ts | Replaces untyped GraphQL responses and SDK callback contexts with compile-time types while preserving the existing request and handler logic. |
| .agents/pm/chores/pm-linear-pfmo.toon | Records the completed typing-cleanup chore and its validation results. |
| .agents/pm/history/pm-linear-pfmo.jsonl | Adds the corresponding chore lifecycle history. |
Reviews (4): Last reviewed commit: "fix: model an explicit GraphQL null data..." | Re-trigger Greptile
|
@greptileai @coderabbitai full review Typing-only refactor eliminating the last 11 source
That last check matters on this fleet: under pm-cli 2026.7.27 a rejected command registration aborts at the offending command and silently drops every later sibling, while Two review notes worth your attention specifically:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@index.ts`:
- Around line 95-98: Update the shared LinearResponse interface’s data property
to explicitly allow null alongside omitted and typed values, using the existing
TData generic without changing the errors field or runtime handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 22dd8d20-2f32-4d8e-9144-5cd22c95d8d0
📒 Files selected for processing (3)
.agents/pm/chores/pm-linear-pfmo.toon.agents/pm/history/pm-linear-pfmo.jsonlindex.ts
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '--- changed files ---'
git diff --name-status HEAD^ HEAD
echo '--- diff (tracked PR change) ---'
git diff --unified=80 HEAD^ HEAD -- index.ts
echo '--- index.ts outline ---'
ast-grep outline index.ts --items all --view expanded || true
echo '--- relevant type declarations and Linear request call sites ---'
rg -n -C 12 \
'interface Linear(Response|GraphQLError|IssuesData|TeamData|TeamNode|ViewerData)|type Linear(Response|GraphQLError|IssuesData|TeamData|TeamNode|ViewerData)|function linearRequest|const linearRequest|function linearRequestOnce|const linearRequestOnce|linearRequest<|linearRequestOnce<|JSON\.parse|isJsonMode|renderImportDryRun|registerPreflight|CommandHandlerContext|ImportExportContext|PreflightOverrideContext' \
index.ts
echo '--- package and compiler context ---'
for f in package.json tsconfig.json; do
if [ -f "$f" ]; then
echo "--- $f ---"
cat "$f"
fi
done
echo '--- authored test changes and coverage references ---'
git diff --name-status HEAD^ HEAD -- '*test*' '*spec*' || true
rg -n -C 4 \
'linearRequest|linearRequestOnce|LinearResponse|isJsonMode|renderImportDryRun|registerPreflight' \
-g '*.{test,spec}.{ts,tsx,js,jsx}' . || trueLength of output: 96163 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '--- locate SDK authoring/type declaration files ---'
fd -a -t f -e d.ts . node_modules 2>/dev/null | rg '/@unbrained/pm-cli/.*/?(sdk/)?authoring|/@unbrained/pm-cli/.*\.d\.ts$' || true
echo '--- authoring symbols and registration signatures ---'
rg -n -C 10 \
'export (interface|type).*(CommandHandlerContext|ImportExportContext|PreflightOverrideContext|ExtensionApi)|interface (CommandHandlerContext|ImportExportContext|PreflightOverrideContext|ExtensionApi)|type (CommandHandlerContext|ImportExportContext|PreflightOverrideContext)|registerPreflight|registerCommand|registerImporter|global|pm_root' \
node_modules/@unbrained/pm-cli 2>/dev/null || true
echo '--- all Linear request uses, including inferred calls ---'
rg -n -C 3 '\blinearRequest(?:Once)?\s*(?:<[^>]+>)?\s*\(' index.ts
echo '--- residual any annotations/assertions in production entrypoint ---'
rg -n ':\s*any\b|\bas\s+any\b|<any>|any\[\]' index.ts || true
echo '--- complete compact diff statistics and non-index artifacts ---'
git diff --check HEAD^ HEAD
git diff --stat HEAD^ HEAD
for f in .agents/pm/chores/pm-linear-pfmo.toon .agents/pm/history/pm-linear-pfmo.jsonl; do
if [ -f "$f" ]; then
echo "--- $f ---"
cat "$f"
fi
doneLength of output: 12460
The generic Using I also confirmed all request call sites are explicitly typed, the source ✅ Action performedFull review finished. Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 56 minutes. |
The GraphQL spec permits a response carrying an explicit 'data: null' root payload alongside errors, not only an omitted data field. Typing it as 'data?: TData' modelled the omitted case alone, which is unsound for any future consumer reading data without optional chaining -- the runtime already handled null correctly, so this closes a type-level gap rather than a behavioural one. Raised by CodeRabbit on review.
|
@greptileai @coderabbitai review
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '--- follow-up commit ---'
git show --no-ext-diff --format=fuller --stat 5e3fef4
echo '--- follow-up diff ---'
git diff --no-ext-diff --unified=60 5e3fef4^ 5e3fef4 -- index.ts
echo '--- index structure ---'
ast-grep outline index.ts --items all --view expanded
echo '--- response types, request boundaries, and data consumers ---'
rg -n -C 10 \
'interface LinearResponse|type LinearResponse|LinearResponse<|function linearRequest(?:Once)?|const linearRequest(?:Once)?|JSON\.parse|\.data\b|data\?' \
index.ts
echo '--- whitespace and full changed-file list ---'
git diff --check 5e3fef4^ 5e3fef4
git diff --name-status 5e3fef4^ 5e3fef4Length of output: 23310
|
What
Removes the 11 remaining
anyannotations inindex.ts, mirroring the proven pm-github PR #18 precedent. Typing refactor only — behaviour is unchanged.A. Linear GraphQL responses (8 sites)
LinearResponseis now a generic envelopeLinearResponse<TData>(data?: TData,errors?: LinearGraphQLError[]);linearRequest/linearRequestOncetake a type parameter so every call site gets a typed response with no cast.LinearIssuesData— paginated issues query infetchAllLinearIssuesLinearTeamData/LinearTeamNode—TEAM_QUERYteam resolution (id, states, labels, cycles; everything optional since Linear may return partial data alongsideerrors)LinearViewerData—viewer { id }credential probe in the preflightissueCreate/issueUpdatemutation sites consume only the error envelope, so they are typedlinearRequest<unknown>— no invented schema mirror.JSON.parsewire boundary keeps its single deserialization cast, nowas LinearResponse<TData>.B. SDK handler/context types (3 sites)
isJsonModeandrenderImportDryRuntakeCommandHandlerContext | ImportExportContext; theregisterPreflightcallback takesPreflightOverrideContext— all imported type-only from@unbrained/pm-cli/sdk/authoring(same subpath as the existingExtensionApiimport, so no runtime module edge for standalone installs).--jsoncontinues to be read fromctx.global.json(the correct SDK contract); defensive?.chains are retained.Gates (all green)
npm run build✅npm test✅ — 63 pass, 0 failnpx tsc --noEmit✅ cleannpm run changelog:check✅grep -nE ':\s*any\b|\bas any\b|<any>|any\[\]' index.ts✅ prints nothingReal activation proof (throwaway workspace, /tmp/pm-linear-proof)
pm item
Summary by Sourcery
Remove remaining untyped Linear GraphQL and SDK context usages by introducing precise TypeScript types while preserving existing behavior.
Enhancements:
Chores:
Summary by cubic
Replaced the remaining 11
anytypes with precise Linear GraphQL and SDK context types, and updated the GraphQL envelope to allowdata: nullper spec. Behavior is unchanged; type safety is improved across requests and handlers.LinearResponse<T>withdata?: T | nulland typederrors; madelinearRequest/linearRequestOncegeneric; added per-operation payload types (LinearIssuesData,LinearTeamData/LinearTeamNode,LinearViewerData); mutations uselinearRequest<unknown>; singleJSON.parsecast toLinearResponse<T>.isJsonModeandrenderImportDryRunasCommandHandlerContext | ImportExportContext, andregisterPreflightasPreflightOverrideContextfrom@unbrained/pm-cli/sdk/authoring.any; retained defensive?.; build, tests, and typecheck pass.Written for commit 5e3fef4. Summary will update on new commits.