当我尝试导入Menu和MenuItem组件时,出现了一个奇怪的编译错误。
Failed to compile
C:/XXXXXXX/ClientApp/node_modules/@progress/kendo-react-layout/dist/npm/panelbar/PanelBar.d.ts
TypeScript error in C:/XXXXXXX/ClientApp/node_modules/@progress/kendo-react-layout/dist/npm/panelbar/PanelBar.d.ts(70,23):
Generic type 'ReactElement<P>' requires 1 type argument(s). TS2314
68 | * @hidden
69 | */
> 70 | onSelect: (child: React.ReactElement<PanelBarItemProps, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)>, expanded: string[]) => void;
| ^
71 | /**
72 | * @hidden
73 | */
注释掉kendo-react-layout导入可消除该错误。我正在使用的Kendo版本是,并且正在使用默认主题。
"@progress/kendo-data-query": "^1.5.2", "@progress/kendo-drawing": "^1.6.0", "@progress/kendo-react-dateinputs": "^3.4.1", "@progress/kendo-react-dialogs": "^3.4.1", "@progress/kendo-react-dropdowns": "^3.4.1", "@progress/kendo-react-grid": "^3.4.1", "@progress/kendo-react-inputs": "^3.4.1", "@progress/kendo-react-intl": "^3.4.1", "@progress/kendo-react-layout": "^3.4.1", "@progress/kendo-theme-default": "^4.3.3",
import * as React from 'react';
import { Menu, MenuItem } from '@progress/kendo-react-layout';
export default () => {
return (
<header>
<Menu>
<MenuItem text="Item1" />
<MenuItem text="Item2" />
<MenuItem text="Item3" />
</Menu>
</header>
);
}
答案 0 :(得分:0)
升级typescript
版本和@types/react
版本可以解决我的问题。
“打字稿”:“ 3.2.2” =>“ 3.4.5”
“ @ types / react”:“ 16.7.1” =>“ 16.9.6”