Files
SuhaibandGitHub ef6ac79d0b feat: detect @typescript/native-preview as alternative TypeScript compiler (#89149)
## What?

This PR adds support for detecting `@typescript/native-preview` as an
alternative TypeScript compiler. When installed, Next.js will no longer
automatically install the `typescript` package.

## Why?

Fixes #88580

Users who want to use `@typescript/native-preview` (a Go-based native
TypeScript compiler) should not be forced to also install the
JavaScript-based `typescript` package. This is especially relevant for
projects using `next.config.ts` where TypeScript support is provided by
Node.js native TS or SWC.

## How?

1. Added `hasNativeTypeScriptPreview()` function to detect if
`@typescript/native-preview` is installed
2. Modified the dependency check logic in `verifyTypeScriptSetup()` to
skip auto-installing `typescript` when the native preview is present
3. Added an informative log message to notify users that some TypeScript
features (like type checking during build) require the standard
`typescript` package
4. Added e2e test to verify the behavior

## Test Plan

- Added new e2e test at `test/e2e/app-dir/typescript-native-preview/`
- The test verifies:
  - Detection message is shown
  - `typescript` is not auto-installed
  - The app still works (SWC/Turbopack handles compilation)
2026-01-30 15:38:14 -08:00
..