Skip to content

refactor(shared): tighten ts-strict typing helpers#5707

Open
rebelchris wants to merge 6 commits intomainfrom
codex/ts-strict-shared-small-pass
Open

refactor(shared): tighten ts-strict typing helpers#5707
rebelchris wants to merge 6 commits intomainfrom
codex/ts-strict-shared-small-pass

Conversation

@rebelchris
Copy link
Contributor

@rebelchris rebelchris commented Mar 11, 2026

Summary

  • tighten shared event/helper typings to reduce explicit any usage for the ts-strict migration
  • make feed settings and zod form helpers preserve callback/form generics more accurately
  • narrow modal swipe and GraphQL extension typing without changing runtime behavior

Testing

  • git diff --check
  • pnpm --filter shared typecheck:strict (fails in this worktree because node_modules is missing and tsc is unavailable)

Preview domain

https://codex-ts-strict-shared-small-pas.preview.app.daily.dev

@vercel
Copy link

vercel bot commented Mar 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
daily-webapp Ready Ready Preview Mar 11, 2026 1:36pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
storybook Ignored Ignored Mar 11, 2026 1:36pm

Request Review

@rebelchris
Copy link
Contributor Author

@claude fix lint and test

@claude
Copy link
Contributor

claude bot commented Mar 11, 2026

Claude finished @rebelchris's task in 2s —— View job


Fixing lint and tests

  • Gather context and read changed files
  • Run lint on shared package — 3 prettier errors in useEventListener.ts
  • Fix lint issues — auto-fixed with lint:fix
  • Run tests on shared package — 2 failures in useEventListener.spec.ts
  • Fix test failures
  • Commit and push

What was fixed

Lint (3 prettier errors in useEventListener.ts): Auto-fixed with lint:fix — formatting issues from the generic type parameter style change.

Tests (2 failures in useEventListener.spec.ts): The PR moved the boolean options check inside useMemo and added options to the dependency array. When the hook is called with an object literal like { passive: true }, a new object reference is created on every render. With options in the deps array, useMemo recomputed on every rerender → new eventOptions reference → useEffect re-ran → event listener added twice.

Fix: Extract boolean options to a stable primitive variable before the memo:

const booleanOptions = typeof options === 'boolean' ? options : undefined;
// deps: [booleanOptions, once, passive, signal] — all primitives, stable across renders

This restores the original correctness (stable deps = no spurious re-subscriptions) while keeping the PR's intent of handling the boolean case inside the memo.
| Branch

…s re-subscriptions

Extract boolean options to a primitive before useMemo to prevent object
reference changes from triggering unnecessary re-runs of the effect.

Co-authored-by: Chris Bongers <rebelchris@users.noreply.github.com>
@rebelchris
Copy link
Contributor Author

@claude still throws some bujild errors:
Type error: Argument of type 'SwipeEventData' is not assignable to parameter of type 'MouseEvent<Element, MouseEvent> | KeyboardEvent'.

@claude
Copy link
Contributor

claude bot commented Mar 11, 2026

Claude finished @rebelchris's task in 1m 41s —— View job


Fixed SwipeEventData type error

  • Gather context
  • Read ShareModal.tsx to understand the type error
  • Fix the type error
  • Commit and push

What was fixed

The PR changed onSwipedDown's parameter from e: any to e: SwipeEventData, but then onRequestClose(e) passed a SwipeEventData where React.MouseEvent | React.KeyboardEvent was expected.

Fix: Cast e.event (the underlying DOM event from the swipe) to React.MouseEvent:

// Before
onRequestClose(e);

// After
onRequestClose(e.event as React.MouseEvent);

SwipeEventData.event is the actual DOM event that triggered the swipe, so casting it to React.MouseEvent is semantically correct here.
| Branch

Co-authored-by: Chris Bongers <rebelchris@users.noreply.github.com>
@rebelchris
Copy link
Contributor Author

@claude the build is still failing what now?

@claude
Copy link
Contributor

claude bot commented Mar 11, 2026

Claude finished @rebelchris's task in 5m 3s —— View job


Fixed build failure

  • Check CI logs and identify the build error
  • Fix type error in auth.ts caused by promisifyEventListener<E = unknown> default
  • Commit and push

Root cause

func.ts changed promisifyEventListener's default from E = anyE = unknown.

In auth.ts, the call omitted the E type parameter:

// Before fix — E defaults to unknown → T inferred as unknown → Promise<unknown>
const promise = promisifyEventListener(
  'native-auth',
  (event) => event.detail,
);
return promise; // ❌ Promise<unknown> not assignable to Promise<NativeAuthResponse | undefined>

Fix: explicit type params at the call site in packages/shared/src/lib/auth.ts:

const promise = promisifyEventListener<
  NativeAuthResponse | undefined,
  NativeAuthResponse | undefined
>('native-auth', (event) => event.detail);

Commit: 8d9dd5e | Branch |

…tiveAuth

E = unknown default no longer infers T as any; must be explicit.

Co-authored-by: Chris Bongers <rebelchris@users.noreply.github.com>
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.

1 participant