TS2440

error TS2440: Import declaration conflicts with local declaration of ‘React‘.

Broken Code ❌

main.ts
1
2
3
4
5
import React from 'react';

declare module React {
type MyCustomType<P> = void;
}

Fixed Code ✔️

You cannot redeclare a module that you are importing, but you can outsource your additional typings to a declaration file in order to apply declaration merging:

index.d.ts
1
2
3
declare namespace React {
type MyCustomType<P> = void;
}