menu
menu copied to clipboard
Unable to use MenuInfo
When attempting to import MenuInfo with:
import { MenuInfo } from 'rc-menu/lib/interface'
I get an error:
Cannot use namespace 'MenuInfo' as a type. TS2709
I think the issue is that the interface is exported without a corresponding declare modifier. I could open a PR, but I can't tell if this is really the root cause. https://github.com/ant-design/ant-design/issues/25467 indicates that the import statement should work and the history of the interface file suggests it's always been exported this way. The only other difference I could think of was a change made to TypeScript itself.
怎么导入 MenuInfo 啊,我也遇到这个问题了。
You can access MenuInfo by using MenuProps
import type { MenuProps } from 'antd'
const onClick: MenuProps['onClick'] = (e) => {
....
}
I hope this help