Files
速冻饺子GitHubvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>Ben Gubler
2b5c714b57 fix: use ESM import instead of triple-slash reference for routes.d.ts (#82867)
## What?

Replace `/// <reference path="./.next/types/routes.d.ts" />` with
`import type {} from './.next/types/routes.d.ts'` in generated
`next-env.d.ts` files.

## Why?

The current implementation uses triple-slash reference directives which
trigger ESLint errors when using the
`@typescript-eslint/triple-slash-reference` rule. This rule is commonly
enabled in TypeScript projects to encourage modern ES module imports
over legacy triple-slash references.

## How?

- Modified `writeAppTypeDeclarations.ts` to generate ESM import
statements instead of triple-slash references
- Updated all create-next-app templates to use the new format
- Updated corresponding unit tests to reflect the new expected output

The change maintains identical TypeScript functionality while improving
ESLint compatibility. The `import type {}` syntax ensures type-only
imports that are properly elided during compilation.

**Testing:**
- Existing unit tests pass with updated expectations
- Verified ESLint `@typescript-eslint/triple-slash-reference` rule no
longer triggers errors
- TypeScript functionality remains unchanged

Fixes [#82828](https://github.com/vercel/next.js/issues/82828)

---------

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Ben Gubler <[email protected]>
2025-08-27 14:57:43 -07:00

7 lines
249 B
TypeScript

/// <reference types="next" />
/// <reference types="next/image-types/global" />
import "./.next/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.