WebStorm + React + Antd 数组类型声明问题Initializer type XXX is not assignable to variable type?

webstorm + React + antd 声明一个数组类型,在使用时提示无法注入此类型 Initializer type
和官网上的写法一模一样呀,tsconfig.json也是脚手架里自带的没有修改过,是什么问题呢?

import type { ProColumns } from '@ant-design/pro-components';


import type { ActionType, ProColumns } from '@ant-design/pro-components';

export default ()=> {
 type RoleData = {
    name: string
  }
  const roleColumns: ProColumns<RoleData>[] = [{
    title: '角色名称',
    dataIndex: 'name',
  },
  {
    title: '创建时间',
    dataIndex: 'createTime'
  }, {
    title: '备注',
    dataIndex: 'remark',
  }]

return (
  <></>
)
}

image.png

wu

阅读 477
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Microsoft
子站问答
访问
宣传栏