Skip to content

relax no-unsafe-* for src/index.ts dispatcher#23

Merged
johncarmack1984 merged 1 commit into
mainfrom
john/eslint-relax-dispatcher
May 6, 2026
Merged

relax no-unsafe-* for src/index.ts dispatcher#23
johncarmack1984 merged 1 commit into
mainfrom
john/eslint-relax-dispatcher

Conversation

@johncarmack1984
Copy link
Copy Markdown
Collaborator

Summary

  • Disable the @typescript-eslint/no-unsafe-* rule family for src/index.ts only
  • Unblocks Specta 2.0.0-rc.25 #22 (Specta 2.0.0-rc.25) without forcing unknown casts in the proxy dispatcher

Why

The runtime proxy dispatcher receives serialized values, applies user-supplied transforms, and forwards them. Static types cannot describe that flow without defeating the purpose; the typed contract lives in generated Specta bindings, not the dispatcher. Forcing unknown (or worse, as casts) at the dispatch layer would just push the lint complaint around without making the runtime any safer.

The no-unsafe-* rules stay active for the rest of the codebase (taurpc Rust crate, examples, future TS code).

Background

#22 introduced a per-element transform inside Array.isArray(input) branch:

const transformed = input.map((value, idx) => {
  return transform?.eventArgs?.[idx]?.(value) ?? value
})

Payload.event.input_type is unknown, but TypeScript's Array.isArray lib predicate is arg is any[], which re-widens to any[] after the guard. The ?? value then taints the callback return to any and trips @typescript-eslint/no-unsafe-return. That's structural; this file's job is exactly that kind of dynamic dispatch.

Test plan

  • pnpm lint:js passes locally with src/index.ts from Specta 2.0.0-rc.25 #22 overlaid
  • pnpm lint:types (tsc) passes
  • dprint check clean on the two changed files

@johncarmack1984 johncarmack1984 merged commit fe1c820 into main May 6, 2026
1 check passed
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