I'm using antd alert component (ts) with styled component
import styled from 'styled-components';
import Alert from 'antd/es/alert';
export const SAlert = styled(Alert)`
&& {
margin-bottom: 24px;
border-radius: 14px;
border: 0;
padding: 8px 12px;
}
`;
enter image description here and on npm i getting following error:
Exported variable 'SAlert' has or is using name 'AlertInterface' from external module
In some articles I've read that it's because of the import name but I've imported different ways. e.g
import {Collapse as MyCollapse} from 'antd';
and still got the same error I see that antd is not exporting AlertInterface and this is causing the issue.
interface AlertInterface extends React.FC<AlertProps> {
ErrorBoundary: typeof ErrorBoundary;
}
declare const Alert: AlertInterface;
This is the solution to not duplicate interface export:
import { ComponentType } from 'react';
import { AlertProps } from 'antd/es/alert';
export const SAlert = styled<ComponentType(AlertProps)>(Alert)`
&& {
margin-bottom: 24px;
border-radius: 14px;
border: 0;
padding: 8px 12px;
}`;