执行 tsc -p tsconfig.build.json之后一直报错
来源:12-6 驯服 tsc - tsconfig 编写第二部分

大什么大
2020-06-30
老师, 不知为何,无法上传图片,只能复制了。。。
一直报错
node_modules/@types/react/index.d.ts:2949:13
2949 samp: React.DetailedHTMLProps<React.HTMLAttributes, HTMLElement>;
~~~~
‘samp’ was also declared here.
node_modules/@types/testing-library__react/node_modules/@types/react/index.d.ts:3053:13 - error TS2717: Subsequent property declarations must have the same type. Property ‘script’ must be of type ‘DetailedHTMLProps<ScriptHTMLAttributes, HTMLScriptElement>’, but here has type ‘DetailedHTMLProps<ScriptHTMLAttributes, HTMLScriptElement>’.
3053 script: React.DetailedHTMLProps<React.ScriptHTMLAttributes, HTMLScriptElement>;
~~~~~~
node_modules/@types/react/index.d.ts:2950:13
2950 script: React.DetailedHTMLProps<React.ScriptHTMLAttributes, HTMLScriptElement>;
~~~~~~
‘script’ was also declared here.
node_modules/@types/testing-library__react/node_modules/@types/react/index.d.ts:3054:13 - error TS2717: Subsequent property declarations must have the same type. Property ‘section’ must be of type ‘DetailedHTMLProps<HTMLAttributes, HTMLElement>’, but here has type ‘DetailedHTMLProps<HTMLAttributes, HTMLElement>’.
3054 section: React.DetailedHTMLProps<React.HTMLAttributes, HTMLElement>;
~~~~~~~
node_modules/@types/react/index.d.ts:2951:13
2951 section: React.DetailedHTMLProps<React.HTMLAttributes, HTMLElement>;
~~~~~~~
‘section’ was also declared here.
node_modules/@types/testing-library__react/node_modules/@types/react/index.d.ts:3055:13 - error TS2717: Subsequent property declarations must have the same type. Property ‘select’ must be of type ‘DetailedHTMLProps<SelectHTMLAttributes, HTMLSelectElement>’, but here has type ‘DetailedHTMLProps<SelectHTMLAttributes, HTMLSelectElement>’.
3055 select: React.DetailedHTMLProps<React.SelectHTMLAttributes, HTMLSelectElement>;
~~~~~~
node_modules/@types/react/index.d.ts:2952:13
2952 select: React.DetailedHTMLProps<React.SelectHTMLAttributes, HTMLSelectElement>;
~~~~~~
‘select’ was also declared here.
node_modules/@types/testing-library__react/node_modules/@types/react/index.d.ts:3056:13 - error TS2717: Subsequent property declarations must have the same type. Property ‘small’ must be of type ‘DetailedHTMLProps<HTMLAttributes, HTMLElement>’, but here has type ‘DetailedHTMLProps<HTMLAttributes, HTMLElement>’.
3056 small: React.DetailedHTMLProps<React.HTMLAttributes, HTMLElement>;
3回答
-
张轩
2020-07-03
同学问题 解决了 是因为 @testing-library/react 这个包 把 @types/react 当作 deps,会安装一次,位置在
node_modules/@types/testing-library__react/node_modules/@types/react/index.d.ts:
我们还单独安装了一次 @types/react,但是这时候出现了这两个文件版本不一致的问题,所以会出现这个错误,提示你有两次重复的定义。这时候你需要把改成同样的版本。在你的代码中我是这样修改的。
- "@types/react": "^16.9.13", + "@types/react": "16.9.33"
我定死在了和另外一个一样的版本就没问题了。
但是我不确定你这个问题是怎样出现的,如果使用 create-react-app 创建,这两个版本应该是完全统一的。
212020-07-03 -
似水流年0709
2020-12-13
如果你修改了@types/react版本还是不行,可以考虑也修改@types/react-dom的版本,我也遇到了这个问题, 受老师启发,我这里不只要解决@types/react的版本问题 同时也修改了@types/react-dom的版本,包括老师后面的npm link 调试react版本时 也要加上react-dom。否则测试autoComplete时也报错。我是这么一起改的 是可以跑起来了,但还是有两个提示错误,
Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of Transition which is inside StrictMode. Instead, add a ref directly to the element you want to reference.
00 -
张轩
2020-07-01
同学 光看错误比较难定位问题 所以想让你提供一下整体的 repo,我可以拿来试试
022020-07-02
相似问题