gpt4 book ai didi

javascript - react typescript 打字不起作用

转载 作者:可可西里 更新时间:2023-11-01 01:49:56 27 4
gpt4 key购买 nike

通过打字安装后,我在终端中收到以下错误

终端错误

error TS2320: Interface 'Element' cannot simultaneously extend types 'ReactElement<any>' and 'ReactElement<any>'.
Named property 'type' of types 'ReactElement<any>' and 'ReactElement<any>' are not identical.

ERROR in /Users/ajvivek/Dev/ES6/motionize-code/typings/globals/react/index.d.ts
(2375,5): error TS1036: Statements are not allowed in ambient contexts.

ERROR in /Users/ajvivek/Dev/ES6/motionize-code/typings/globals/react-dom/index.d.ts
(69,5): error TS2309: An export assignment cannot be used in a module with other exported elements.

ERROR in /Users/ajvivek/Dev/ES6/motionize-code/node_modules/@types/react-dom/index.d.ts
(19,31): error TS2315: Type 'DOMAttributes' is not generic.

ERROR in /Users/ajvivek/Dev/ES6/motionize-code/node_modules/@types/react-dom/index.d.ts
(44,60): error TS2315: Type 'DOMAttributes' is not generic.

ERROR in /Users/ajvivek/Dev/ES6/motionize-code/node_modules/@types/react/index.d.ts
(2368,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'a' must be of type 'HTMLProps<HTMLAnchorElement>', but here has type 'HTMLProps<HTMLAnchorElement>'.

ERROR in /Users/ajvivek/Dev/ES6/motionize-code/node_modules/@types/react/index.d.ts
(2369,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'abbr' must be of type 'HTMLProps<HTMLElement>', but here has type 'HTMLProps<HTMLElement>'.

index.d.ts
/// <reference path="globals/react/index.d.ts" />
/// <reference path="globals/react-dom/index.d.ts" />

tsconfig.json

{
"compilerOptions": {
"module": "commonjs",
"sourceMap": true,
"noImplicitAny": true,
"target": "es5",
"jsx": "react"
},
"files": [
"./app/app.tsx",
"./app/Hello.tsx",
"typings/index.d.ts"
],
"exclude": [
"node_modules"
]
}

我已遵循 https://www.typescriptlang.org/docs/handbook/react-&-webpack.html 中提供的文档

不确定我错过了什么?

有人遇到这个问题吗?

最佳答案

我终于想通了这个问题。

我继续通过 tsd 安装类型,然后 typings 导致重复输入。

删除了 @types 文件夹以解决我的问题。

关于javascript - react typescript 打字不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39992690/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com