mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### Why? VS Code passes a maximum hover length and verbosity level to TypeScript's `getQuickInfoAtPosition` API when a user expands a hover. The Next.js TypeScript plugin intercepted that call and forwarded the file name and position, dropping the remaining arguments. The plugin also replaced TypeScript's `QuickInfo` object when it added config documentation, which discarded native fields such as `canIncreaseVerbosityLevel`. As a result, hovers for Next.js config exports could not expand and lost native type information. This supersedes #86290 with a narrower behavior change. The plugin preserves native `QuickInfo` when it adds documentation to valid config values and config identifiers. Invalid config values keep the existing synthesized override, and hovers inside function initializers retain TypeScript's existing behavior. x-ref: https://github.com/microsoft/vscode/issues/232685#issuecomment-3484167019 | Before | After | |--------|-------| | <img width="1656" height="390" alt="Config hover without expandable metadata" src="https://github.com/user-attachments/assets/ed39a851-7096-448b-bffe-55c5320c1713" /> | <img width="1668" height="384" alt="Config hover with expandable metadata" src="https://github.com/user-attachments/assets/0a3a0cbc-5c75-4b6f-90fc-bbcef028d06b" /> | ### How? The plugin forwards all QuickInfo arguments to TypeScript and passes the native result into the config hover rules. For valid config values and identifiers, those rules copy the native `QuickInfo` fields and append the Next.js documentation. They synthesize the existing fallback when TypeScript returns no QuickInfo. Focused tests cover argument forwarding, metadata preservation, missing native QuickInfo, invalid config values, and function config boundaries. ### Test plan Open a minimal Next.js app in Cursor with workspace TypeScript 6.0.2 and the package built from this PR. Hover `export const metadata: Metadata`, then select the expansion control. The hover expands from `Metadata` to its full property type while the Next.js config documentation and link remain visible. <!-- NEXT_JS_LLM -->
typescript-plugin fixture
This fixture is used to test the TypeScript plugin. The plugin only applies to VSCode so manual testing in VSCode is required.
Getting started
- Install the dependencies with
pnpm install - Open any TypeScript file of this fixture in VSCode
- Change TypeScript version to use Workspace version (see https://nextjs.org/docs/app/api-reference/config/typescript#typescript-plugin)
Tests
Client component prop serialization
app/client.tsx#ClientComponent has props that can and can't be serialized.
Ensure the current comments still describe the observed behavior.
app/error.tsx#Error and app/global-error.tsx#GlobalError have reset and
retry props that should be excluded from the serialization check.
Client Boundary
client-boundary/app/non-serializable-action-props.tsxhas examples of Server Action props that can't be serialized, which is allowed.client-boundary/app/non-serializable-props.tsxhas examples of props that can't be serialized.client-boundary/app/serializable-props.tsxhas examples of props that can be serialized.
Metadata
metadata/app/metadata/completionhas examples of metadata and generateMetadata completions.metadata/app/metadata/missing-type-warninghas examples of metadata and generateMetadata missing type warnings.metadata/app/metadata/clienthas examples of metadata and generateMetadata not allowed in a client component.