'Adding `import` statement to `global.d.ts` destroys type and module declarations

In my Next.js web project, my types/global.d.ts starts like this:

declare module 'react-zeroconfig-components'

interface Product {
  ...
}

I’m using openapi-typescript to generate types from my Swagger OpenAPI definitions, but when I import my generated swagger.ts file:

import { definitions } from 'types/swagger'

declare module 'react-zeroconfig-components'

interface Product {
  ...
}

…none of the other types/interfaces in global.d.ts work any longer:

Type error: Cannot find name 'Product'.

and also the declare module stops working:

Could not find a declaration file for module 'react-zeroconfig-components'

What is wrong here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source