0

当我尝试导入 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 导入可以消除错误。我正在使用的剑道版本是,并且正在使用默认主题。

"@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>
    );
}
4

1 回答 1

0

升级typescript版本和@types/react版本为我解决了问题。

“打字稿”:“3.2.2”=>“3.4.5”

“@types/react”:“16.7.1”=>“16.9.6”

于 2019-10-15T05:36:42.890 回答