Remove unnecessary `as any` casts (#100418)
## Summary Deletes 69 `as any` casts from `packages/next/src` (466 → 397) where the existing types already make the cast unnecessary. Each change only removes ` as any`, plus any parentheses that become redundant. Nothing else is added or changed: no new declarations, fields, annotations, helpers, or replacement assertions. The emitted JavaScript is identical, so there is no runtime change. How the casts were found: 1. Delete every `as any` in `packages/next/src`, locating them through the TypeScript AST rather than text search. 2. Run `tsc`, put back each cast whose removal caused an error, and repeat until clean. 3. Retry the casts that were put back one at a time, so removals in the same file can't mask each other. Casts that need a type change, a declaration, or code changes to go away are left to #100419. ## Verification - Transpiled each changed file on `canary` and on this branch with `ts.transpileModule` (the package's compiler options, comments stripped) and compared the output, ignoring whitespace and semicolons: 44/44 identical. - `tsc --noEmit` passes for `packages/next` and for the root project. - Colocated jest suites for the touched files pass (9 suites). <!-- NEXT_JS_LLM -->
Showing
Please
register
or
sign in
to comment