-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use tsup to generate .d.ts
files with svgr
#570
Comments
@laozhu Did you find a solution for this? |
@thedaviddias I ended up writing the type definitions manually. declare module '@scope-name/icons' {
type ReactComponent = React.FC<
React.SVGProps<SVGSVGElement> & {
title?: string | undefined;
}
>;
const Sms: ReactComponent;
} |
tsup.config.ts import svgrPlugin from 'esbuild-plugin-svgr';
import { defineConfig } from 'tsup';
export default defineConfig({
...,
esbuildPlugins: [svgrPlugin({ template })],
});
function template(variables, { tpl }) {
return tpl`
${variables.imports};
${variables.interfaces};
const ${variables.componentName} = (${variables.props}) => (
${variables.jsx}
);
${variables.exports};
export const ReactComponent = ${variables.componentName};
`;
} it works for me |
SVG was compiled successfully, by using
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First I have a svg file
Then I use svgr to import it as react component
I use vite and vite-plugin-svgr to bundle the icon libraries (success)
Try to generate .d.ts files with below cli (failed)
If I want to use tsup for dts only, can I have a method to avoid this error?
Upvote & Fund
The text was updated successfully, but these errors were encountered: