Skip to content

On every build my custom *.svg type declaration is removed for some reason #26560

Closed
@gherciu

Description

@gherciu

What version of Next.js are you using?

11.0.1

What version of Node.js are you using?

14

What browser are you using?

What operating system are you using?

How are you deploying your application?

Describe the Bug

I have a custom declaration for *.svg in next-env.d.ts

declare module '*.svg' {
  export const ReactComponent: any
  const content: {
    ReactComponent: ReactComponent
  }
  export default content
}

and a import in my app (I'm using @svgr to handle svg imports)

import { ReactComponent as Logo } from '../../public/static/logo.svg'

And for some reason when I'm trying to start the app Next removes this TS declaration from next-env.d.ts
And that results in TS errors because your default declaration just exports any

Module '"*.svg"' has no exported member 'ReactComponent'. Did you mean to use 'import ReactComponent from "*.svg"' instead?

Expected Behavior

I'm expecting that custom TS declarations will be not removed because that doesn't make any sense...if someone uses strict TS..to fix that users should only add a TS ignore comment

To Reproduce

add a custom TS declaration in next-env.d.ts....and run next dev.....and it will remove this custom dts declaration

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