Skip to content

refactor: effect/avoid-any and typescript/no-explicit-any to zero - #619

Merged
thomasfosterau merged 2 commits into
trunkfrom
lint-avoid-any
Nov 12, 2026
Merged

thomasfosterau merged 2 commits into
trunkfrom
lint-avoid-any

Conversation

@thomasfosterau

@thomasfosterau thomasfosterau commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Part of #533 (effect/avoid-any) and #536 (typescript/no-explicit-any). Follow-up for the remaining seams: #623.

effect/avoid-any 122 -> 0 (27 as any, 95 as unknown as T). typescript/no-explicit-any was off; enabled at error it reported 251 sites, now 0. Both warn/off lines are gone from vite.config.ts (no-explicit-any stays an explicit error, since it is outside the lint categories) and the eight inline disables in Registry.ts are removed. No inline disables or overrides added.

How: Schema.Codec<any, string> id bounds -> Codec<unknown, string>; any in contravariant positions -> never; erased apis -> generics / HttpApi.Top; infer _X in conditional types; Family<..., any> -> an AnyFamily union. Double casts became, in order of preference: overloaded function declarations with an erased implementation signature (Resource.attributeKeys / relationshipKeys / sortable / annotate, Include.paths, Document.wire / LinkageDocument, Atomic.Operations, Assemble.toWireSafeResource, Query.bracketKeys / bracketPageKeys, conformance/core.discover, and the *AttributeFields helpers); a precise type (Client.decodeInput constrained to a codec; example and test run helpers typed by the layer they provide plus Registry.platformLayer); a single as T with a // SAFETY: comment (ApiError encode, Resource.make's updateInput, the test router layers, Conformance). Tests use toHaveProperty / typed structural views instead of as any. test/include-path-member-union.types.ts keeps its any-path probe via ReturnType<typeof JSON.parse>.

Function.cast count

Before this revision: about 57 cast( call sites across src, tests and examples (the first PR head). After: 11 lines (13 casts), listed below and in #623.

Verification

Head 1a60ec36fb11627575b5c542849b61e8fb285f90, rebased on origin/trunk (includes #594, #615, #618, #621) after pnpm install.

  • pnpm install --frozen-lockfile - pass
  • vp run build - pass
  • vp check - pass (0 errors)
  • vp run check - pass (--concurrency-limit 1; includes typecheck:dist and the examples)
  • vp run -r test:unit - pass (4010 + 73 + 56 + 50 tests)
  • vp run docgen - pass
  • vp run test:coverage, then fallow audit --base origin/trunk - verdict warn (0 introduced complexity; 3 duplication groups: the already-duplicated example sortBy and two sibling Endpoint blocks whose lines changed)

Lint deltas against the tree before this work (vp lint; rules trunk fixed since then are at zero): avoid-any -122, no-explicit-any -251 (newly enabled), no-chained-type-assertions -95, require-safety-comment-for-type-assertion -223, casting-awareness -80, no-unsafe-type-assertion -106, any-unknown-in-error-context -23, prefer-option-over-null -2. One rule grows: effecttsgo/unsafe-effect-type-assertion 24 -> 36 (+12), from the single as Layer.Layer<never, never, HttpRouter.HttpRouter> router-layer assertions (11 in tests, 1 in src/Conformance.ts) that replaced as unknown as; each has a SAFETY comment. Removing them needs typed group layers; recorded in #623.

Changeset

  • .changeset/no-explicit-any.md - minor, marked Breaking (types), with migration notes for Registry, Client.decodeInput and the attribute-field helpers.

Notes

Remaining double-assertion seams, still cast(...) from effect/Function (reasons in #623):

  • src/Registry.ts:346 (2 casts: the dynamic fold and the group layer)
  • src/ApiError.ts:399
  • src/Endpoint.ts:2548, src/Endpoint.ts:4439
  • src/Resource.ts:2386, src/Resource.ts:3639, src/Resource.ts:3970
  • src/internal/codecs.ts:131
  • tests: src/Endpoint.test.ts:314, src/Idempotency.test.ts:246, src/Endpoint.location.test.ts:68

Other points: ResourceHandlers.make / readOnly return NoInfer<...> so the unknown requirement channel in Registry.HandlersFor is not inferred from a satisfies context. The example run helpers now also provide Registry.platformLayer (previously the type system was silenced). Touching examples/github/handlers.ts can make fallow flag two untouched functions there (estimated coverage).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY

@changeset-bot

changeset-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c0749e9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@thomasfosterau/effect-jsonapi Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Replace every explicit any with the precise type, unknown, never in
contravariant positions or a constrained generic; every as-unknown-as
becomes an overload, a typed seam or a counted single assertion with a
SAFETY comment. Removes the rules' warn/off lines and the inline disables
in Registry.ts.

Part of #533, #536.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y5G6PMempKsgjiV1NDcCJY

# Conflicts:
#	src/Group.flat.test.ts
#	vite.config.ts
@thomasfosterau
thomasfosterau merged commit dbae674 into trunk Nov 12, 2026
4 checks passed
@thomasfosterau
thomasfosterau deleted the lint-avoid-any branch November 12, 2026 08:36
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.

2 participants