From 6de34e61c864716fa99c52fa437193ea83065ba2 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 21 Feb 2024 15:36:54 +0800 Subject: [PATCH 1/2] feat(module-tools): improve svg typing for SVGR --- .changeset/tough-icons-help.md | 7 +++++++ packages/solutions/module-tools/lib/types.d.ts | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .changeset/tough-icons-help.md diff --git a/.changeset/tough-icons-help.md b/.changeset/tough-icons-help.md new file mode 100644 index 000000000000..36ee44b9efee --- /dev/null +++ b/.changeset/tough-icons-help.md @@ -0,0 +1,7 @@ +--- +'@modern-js/module-tools': patch +--- + +types(module-tools): improve svg typing for SVGR + +types(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' { From 624f2ad59716ad0819aa2661e3743cd57d87aa34 Mon Sep 17 00:00:00 2001 From: neverland Date: Wed, 21 Feb 2024 15:37:16 +0800 Subject: [PATCH 2/2] chore: upd --- .changeset/tough-icons-help.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/tough-icons-help.md b/.changeset/tough-icons-help.md index 36ee44b9efee..4ed2fcfb5bf4 100644 --- a/.changeset/tough-icons-help.md +++ b/.changeset/tough-icons-help.md @@ -2,6 +2,6 @@ '@modern-js/module-tools': patch --- -types(module-tools): improve svg typing for SVGR +feat(module-tools): improve svg typing for SVGR -types(module-tools): 优化 svg 类型定义 +feat(module-tools): 优化 svg 类型定义