通过打字安装后,我在终端
中收到以下错误终端错误
forceLyteboxInit = function () {
setTimeout(
function ()
{
initLytebox();
}, 500);
}
$scope.figureOutTodosToDisplay();
$scope.pageChanged = function () {
$scope.figureOutTodosToDisplay();
forceLyteboxInit();
};
index.d.ts
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>'.
tsconfig.json
/// <reference path="globals/react/index.d.ts" />
/// <reference path="globals/react-dom/index.d.ts" />
我已按照https://www.typescriptlang.org/docs/handbook/react-&-webpack.html
中提供的文档进行操作不确定我错过了什么?
有人面临这个问题吗?
答案 0 :(得分:11)
我终于找到了问题。
我继续通过 tsd 安装类型,然后打字导致重复输入。
删除 @types 文件夹以解决我的问题。
答案 1 :(得分:9)
万一其他人偶然发现这一点,我的@types/react
和@types/react-dom
软件包之间存在不匹配时也会出现此错误。我最后删除了@types/react
中的package.json
条目,因为它@types/react-dom
会自动包含该条目。