Skip to content

Type definitions file getting overwritten on build and dev  #26622

@azzazkhan

Description

@azzazkhan

What version of Next.js are you using?

11.0.1

What version of Node.js are you using?

14.16.0

What browser are you using?

Chrome version 91.0.4472.114 (Official Build) (64-bit)

What operating system are you using?

Windows 10 Home (64-bit)

How are you deploying your application?

next dev/next build

Describe the Bug

When running next build or next start the configured next-env.d.ts gets overwritten and all configurations are removed. I'm using the next-page-transitions package to add transition effects on navigation but when I import the package typescript yells that no type definitions found for package next-page-transitions.

To solve this I added custom type declarations for the next-page-transitions and .svg files, by doing so my next-env.d.ts files looks like this.

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

declare module "next-page-transitions";

declare module "*.svg" {
  content: string;
  export default content;
}

But when I run next build or next dev commands it overwrites my next-env.d.ts file to this

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

BTW I'm using the yarn package manager and using the yarn run dev and yarn run build commands. Due to this bug, I have to rewrite the file every time I need to start the server.

Expected Behavior

Should not overwrite the type declaration file.

To Reproduce

Just initialize a new Next.js project with yarn create next-app --typescript and add type declarations for packages in next-env.d.ts file or follow up using this repository

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