chore: enforce exhaustive switch handling

This commit is contained in:
Neil
2026-05-30 13:18:12 -07:00
parent 36d326c3f9
commit 181741d769
38 changed files with 159 additions and 85 deletions
+1
View File
@@ -274,6 +274,7 @@ export function normalizeFieldValue(
.filter((u): u is GitHubProjectUser => u !== null)
return { kind: 'users', fieldId, users }
}
case undefined:
default:
// Unknown __typename → forward-compat: drop silently, do not throw,
// do not classify as drift (see design §Error Handling).
+6 -10
View File
@@ -62,13 +62,10 @@ function graphqlValueForFieldMutation(value: GitHubProjectFieldMutationValue): s
return 'number: $value'
case 'date':
return 'date: $value'
default:
// Why: defensive default. If a new mutation kind is added to the type
// but not handled here, returning undefined would silently produce a
// broken GraphQL query. Throw so updateProjectItemFieldValue can map it
// to a validation_error rather than dispatching a malformed mutation.
throw new UnknownFieldMutationKindError((value as { kind: string }).kind)
}
// Why: keep a runtime guard for malformed IPC payloads while lint enforces
// that every typed mutation kind is handled above.
throw new UnknownFieldMutationKindError((value as { kind: string }).kind)
}
function mutationValueVar(value: GitHubProjectFieldMutationValue): {
@@ -86,11 +83,10 @@ function mutationValueVar(value: GitHubProjectFieldMutationValue): {
return { type: 'Float!', val: value.number }
case 'date':
return { type: 'Date!', val: value.date }
default:
// Why: see graphqlValueForFieldMutation — surface unknown kinds loudly
// instead of returning undefined and dispatching an invalid mutation.
throw new UnknownFieldMutationKindError((value as { kind: string }).kind)
}
// Why: see graphqlValueForFieldMutation — surface unknown kinds loudly
// instead of returning undefined and dispatching an invalid mutation.
throw new UnknownFieldMutationKindError((value as { kind: string }).kind)
}
export async function updateProjectItemFieldValue(