Skip to content

next-env.d.ts is regenerated on each build #26533

@brc-dd

Description

@brc-dd

What version of Next.js are you using?

11.0.1

What version of Node.js are you using?

14.7.0

What operating system are you using?

Windows 10 (21390.1)

How are you running your application?

next build && next start

Describe the Bug

The content of next-env.d.ts is being replaced by the following code each time I run next build or simply next:

/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

Expected Behavior

Changes in next-env.d.ts should be respected. Quoting docs (emphasis mine):

A file named next-env.d.ts will be created in the root of your project. This file ensures Next.js types are picked up by the TypeScript compiler. You cannot remove it, however, you can edit it (but you don't need to).

To Reproduce

yarn create next-app --ts test-app
cd test-app
echo "// just a comment to show" >> next-env.d.ts
cat next-env.d.ts
yarn build
cat next-env.d.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue was opened via the bug report template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions