mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
2b5c714b57
## 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]>
7 lines
249 B
TypeScript
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.
|