react-spring 类型错误,Property ‘children‘ does not exist on type ‘IntrinsicAttributes & AnimatedProps

在使用@react-spring/web的animated组件时发现了一个类型错误,有issue:https://github.com/pmndrs/react-spring/issues/2358

但是我没找到解决方案

所以决定自己修改原类型文件,注意⚠️这只是个临时的解决办法,尚不清楚对其他类型是否有影响

添加补丁:

diff --git a/node_modules/@react-spring/web/dist/react-spring_web.modern.d.ts 
b/node_modules/@react-spring/web/dist/react-spring_web.modern.d.ts
index f647f1b..a18ef5c 100644
--- a/node_modules/@react-spring/web/dist/react-spring_web.modern.d.ts
+++ b/node_modules/@react-spring/web/dist/react-spring_web.modern.d.ts
@@ -24,7 +24,9 @@ type AnimatedComponent<T extends ElementType> = ForwardRefExoticComponent<Animat
 }>>;
 /** The props of an `animated()` component */
 type AnimatedProps<Props extends object> = {
-    [P in keyof Props]: P extends 'ref' | 'key' ? Props[P] : AnimatedProp<Props[P]>;
+    [P in keyof Props]: P extends 'ref' | 'key' | 'children' ? Props[P] : 
AnimatedProp<Props[P]>;
+} & {
+    children?: React.ReactNode;
 };
 type StyleProps = Merge<CSSProperties, TransformProps>;
 type StylePropKeys = keyof StyleProps;

不知道怎么添加补丁可以看:怎么修改node_modules里的文件,怎么使用patch-package修改node_modules的文件,怎么修改第三方库原文件。-优快云博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

学途路漫漫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值