diff --git a/.changeset/tough-icons-help.md b/.changeset/tough-icons-help.md new file mode 100644 index 000000000000..4ed2fcfb5bf4 --- /dev/null +++ b/.changeset/tough-icons-help.md @@ -0,0 +1,7 @@ +--- +'@modern-js/module-tools': patch +--- + +feat(module-tools): improve svg typing for SVGR + +feat(module-tools): 优化 svg 类型定义 diff --git a/packages/solutions/module-tools/lib/types.d.ts b/packages/solutions/module-tools/lib/types.d.ts index f6247c73e668..2d9cb84115ea 100644 --- a/packages/solutions/module-tools/lib/types.d.ts +++ b/packages/solutions/module-tools/lib/types.d.ts @@ -34,8 +34,18 @@ declare module '*.webp' { } declare module '*.svg' { - const src: string; - export default src; + import * as React from 'react'; + + export const ReactComponent: React.FunctionComponent< + React.SVGProps + >; + + /** + * The default export type depends on the asset.svgr.exportType config, + * it can be a string or a ReactComponent + * */ + const content: any; + export default content; } declare module '*.css' {