next.js
b58d9840 - Allow `unstable_retry` from TS plugin check in Next.js Error APIs (#94460)

Commit
43 days ago
Allow `unstable_retry` from TS plugin check in Next.js Error APIs (#94460) ### What? Stop the Next.js TypeScript plugin from flagging the framework-injected `unstable_retry` prop in `error.tsx` and `global-error.tsx` with error `71007` (`INVALID_CLIENT_ENTRY_PROP`). The plugin already exempts `reset`; this extends that exemption to `unstable_retry`. ### Why? `unstable_retry` is injected by the framework into error boundaries: it is part of the `ErrorInfo` type (`error`, `reset`, `unstable_retry`) in `packages/next/src/client/components/error-boundary.tsx` and is passed to the user's error component, not supplied by the user. Like `reset`, it therefore does not need to be serializable. The file-convention docs (`docs/01-app/03-api-reference/03-file-conventions/error.mdx`) document `unstable_retry` as an error-component prop (added in `v16.2.0`) and recommend it over `reset`. The exact documented pattern, `export default function Error({ error, unstable_retry })`, was being false-flagged by the plugin, so a user copying the docs would hit a spurious diagnostic. <img width="2930" height="1110" alt="image" src="https://github.com/user-attachments/assets/7c7efefe-f9df-448a-9fd6-218c51bc8bd1" /> ### How? Extend the existing error-file `reset` exemption in `packages/next/src/server/typescript/rules/client-boundary.ts` to also allow `unstable_retry`. The exemption stays scoped to those two prop names in `error` / `global-error` files; every other non-serializable function prop is still flagged. Add regression tests for both `error.tsx` and `global-error.tsx`, each with a `_notExempt` negative control that confirms the exemption stays scoped (an ordinary function prop is still flagged). Update the manual VSCode fixtures and the test README to match. ### Verification - `pnpm test-dev-turbo test/development/typescript-plugin/client-boundary/client-boundary.test.ts` (5/5 passed; the harness loads the compiled plugin from `dist`, so green also confirms the build reflects the change) - `pnpm --filter=next types` (passed) - `pnpm --filter=next build` (passed) - `pnpm typescript` root `tsc` for the changed test files (passed) - Not run: full CI suite (will run on the PR) <!-- NEXT_JS_LLM_PR -->
Author
Parents
Loading