-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
react ts提示异常 #11097
Comments
我也遇到了相同的问题 |
使用 React,请安装 @tarojs/plugin-framework-react |
有解决办法嘛 |
有临时解决方法吗? |
上面已经说了咯 |
上面的我加了没用
…Sent from my iPhone
On Jan 17, 2022, at 16:13, Zakary ***@***.***> wrote:
有临时解决方法吗?
上面已经说了咯
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.
|
用npm 6安装没问题,用npm8安装有问题 |
npm8也有一样问题 |
跟这个issues问题一样,参考以下操作就可以临时解决了,手动删除不科学,等版本迭代吧 |
@EdivenH @zhangxf97 @gitlun @khronosleung @zomem 新建了个 React TS 项目测试,没有发现该问题。 按 @khronosleung @zomem 的说法,问题是 分析 |
@ZakaryCode 兄弟,问题关的有点儿勤~ 问题还没有彻底解决,希望重开此问题。 |
这个问题的确没有复现额,如果各位排查后还有问题,欢迎提供更详细的信息,随时 reopen 的 |
背景:因为升级项目package.json的taro依赖包版本,删除整个 node: 分析了
"@tarojs/webpack-runner": {
"version": "3.4.0",
"resolved": "https://registry.npmmirror.com/@tarojs/webpack-runner/download/@tarojs/webpack-runner-3.4.0.tgz",
"integrity": "sha512-kflSpvP4L+VAD3SMTCsiFQ1tAITySocX7hbQvsrsiKj2DrlYaDu7RU2JjI15k5SS+bh3aYnX4U14xGLu4XjvJw==",
"dev": true,
"requires": {
"@babel/core": "^7.14.5",
"@tarojs/components": "3.4.0",
"@tarojs/helper": "3.4.0",
"@tarojs/plugin-framework-react": "3.4.0",
"@tarojs/plugin-framework-vue2": "3.4.0",
"@tarojs/plugin-framework-vue3": "3.4.0",
// ....
},
"dependencies": {
// ....
}
}
"node_modules/@tarojs/plugin-framework-vue3": {
"version": "3.4.0",
"resolved": "https://registry.npmmirror.com/@tarojs/plugin-framework-vue3/download/@tarojs/plugin-framework-vue3-3.4.0.tgz",
"integrity": "sha512-FsGXM0aw+2s1GawZbHPYL/yV/cd89XNqge4phVMi93YFrrMN/DPgR1fbox+Ehdr5j0GjyWVOj8vHElFlAXS1dQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@tarojs/helper": "3.4.0",
"@tarojs/runner-utils": "3.4.0",
"@tarojs/runtime": "3.4.0",
"@tarojs/shared": "3.4.0",
"webpack": "4.46.0"
},
"peerDependencies": {
"vue": "^3.0.0"
}
}
"vue": {
"version": "3.2.29",
"resolved": "https://registry.npmmirror.com/vue/download/vue-3.2.29.tgz",
"integrity": "sha512-cFIwr7LkbtCRanjNvh6r7wp2yUxfxeM2yPpDQpAfaaLIGZSrUmLbNiSze9nhBJt5MrZ68Iqt0O5scwAMEVxF+Q==",
"dev": true,
"peer": true,
"requires": {
"@vue/compiler-dom": "3.2.29",
"@vue/compiler-sfc": "3.2.29",
"@vue/runtime-dom": "3.2.29",
"@vue/server-renderer": "3.2.29",
"@vue/shared": "3.2.29"
}
} 发现在npm@8, {
"name": "package-a",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"license": "ISC",
"dependencies": {
"lodash": "^4.17.15"
},
"devDependencies": {
"react": "^16.13.0"
},
"peerDependencies": {
"query-string": ">7.0.0"
}
} npm install |
vue 与 react 是不相容的,强行把二者捏在一块儿,总归有些不妥当~ |
@Chen-jj @ZakaryCode 目前更新到taro 3.4.1,问题依旧,确实删除了node_modues @VUE 的文件夹后,报错消失。希望Taro团队可以跟进一下哈,很多人报错,确实是有问题的。 |
看来是这个问题,我们再追踪一下 |
Hello~ 你的问题楼上已经提供了解决方案,如果没有更多的问题这个 issue 将在 7 天后被自动关闭。 如果您在这 7 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。 Good luck and happy coding~ |
更新到taro 3.4.1,遇到同样问题,持续更进。 |
补充关于楼上提到的 redux 引起的类型问题,虽然报错类似,但引发的原因是不一样的。
版本号指定为 解决办法
{
"resolutions": {
"@types/react": "17.0.2"
}
}
|
试一下安装或者升级@types/react-dom |
node v17.0.1 , npm 8.1.0 使用此方法成功解决 |
还是有,好恶心啊! |
我这边引起这个问题是因为 安装了 @codedart2018 你试试,安装对应版本的react-dom |
"react": "17.0.0", 都改成 17,我解决了 |
这个问题在yarn里也同样存在. 用上面大家的玄学貌似都无法曲线救国 |
尝试了一下,在 package.json 里增加 resolutions 节点是有效的 |
复现
点击定义进去发现 仓库为monorepo,有react的项目,也有vue的项目,所以不能移除两者的类型声明文件。 解决方法
|
补充一下,使用的taro版本为3.5 |
版本 3.2,删除 node_modules/@types 下的所有的 namespace JSX{} 有用 |
6 现在都不出一个版本解决这个问题吗 |
3.6.2的版本里还是存在这个问题,用npm、yarn以及npx创建项目都试过了,一直解决不了 |
检查当前vscode用的 type TestJsx = JSX.Element 鼠标悬浮到 |
Disable all vue-related extension packages of vscode, which is effective for me. It is recommended to try it out. |
我是安装 |
=。- 因为 |
Set the version of @types/react as follows "@types/react": "^17.0.44". |
我这边是monorepo,因为升级个别子项目的依赖包,导致了根目录里的node_modules和taro子工程里的node_modules安装了两个版本的@types/react 可以根据上边这个引用里提到的方法。点击一下JSX后看看跳到哪里去了来判断是跳到子工程自己的包,还是根目录下统一的包。 |
yarn add -D @types/react |
相关平台
微信小程序
复现仓库
https://github.com/NervJS
小程序基础库: 2.21.2
使用框架: React
复现步骤
从@tarojs/components引入 View Text 组件,ts 报错
“View”不能用作 JSX 组件。
其元素类型 "ReactElement<any, any> | Component<ViewProps, any, any> | null" 不是有效的 JSX 元素。ts(2786)
期望结果
ts 正确提示
实际结果
ts报错
环境信息
The text was updated successfully, but these errors were encountered: