Skip to content

Fix TypeScript optional reducer params to allow omitted keys#4518

Open
akshxdevs wants to merge 1 commit intoclockworklabs:masterfrom
akshxdevs:fix/ts-optional-reducer-params
Open

Fix TypeScript optional reducer params to allow omitted keys#4518
akshxdevs wants to merge 1 commit intoclockworklabs:masterfrom
akshxdevs:fix/ts-optional-reducer-params

Conversation

@akshxdevs
Copy link

Summary

Fix TypeScript row inference so .optional() fields become optional object keys instead of required keys whose values may be undefined.

This resolves the reducer/view parameter typing issue described in #4516, where callers were forced to explicitly pass undefined for omitted optional fields.

Changes

  • update InferTypeOfRow to split required and optional row keys
  • add a regression type test for omitted optional fields
  • loosen internal stored view function param typing to avoid an internal assignability issue exposed by the stricter row inference
  • align the package typecheck command with the existing .test-d.ts style type tests

Example

Before:

await conn.reducers.updateCategory({
id: BigInt(1),
name: "updated category name",
buttonText: undefined,
headerText: undefined,
deleted: undefined,
});

After:

await conn.reducers.updateCategory({
id: BigInt(1),
name: "updated category name",
});

Verification

pnpm test:typecheck

Closes #4516

@CLAassistant
Copy link

CLAassistant commented Mar 2, 2026

CLA assistant check
All committers have signed the CLA.

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.

Typescript optional values should also be "key optional"

2 participants