running-elephant / datart

Datart is a next generation Data Visualization Open Platform
https://running-elephant.github.io/datart-docs/
Apache License 2.0
1.96k stars 589 forks source link

编译前端时报错 #322

Closed feature09 closed 2 years ago

feature09 commented 2 years ago

下载的最新的版本,datart-1.0.0-alpha.3

√ Webpack
  Compiled successfully in 7.86m

i 「wds」: Project is running at http://10.30.30.168/
i 「wds」: webpack output is served from
i 「wds」: Content not from webpack is served from D:\data\datart\datart-1.0.0-alpha.3\frontend\public
i 「wds」: 404s will fallback to /
Starting the development server...
Failed to compile.

D:/data/datart/datart-1.0.0-alpha.3/frontend/src/app/components/Tree/index.tsx
TypeScript error in D:/data/datart/datart-1.0.0-alpha.3/frontend/src/app/components/Tree/index.tsx(27,12):
No overload matches this call.
  Overload 1 of 2, '(props: Omit<Omit<Pick<TreeProps<DataNode | BasicDataNode> & { children?: ReactNode; } & { ref?: Ref<Tree<DataNode>> | undefined; }, "ref"> & Partial<...> & Partial<...>, never> & Partial<...>, "theme"> & { ...; } & { ...; }): ReactElement<...>', gave the following error.
    Type '{ showLine?: boolean | { showLeafIcon: boolean; } | undefined; className?: string | undefined; multiple?: boolean | undefined; autoExpandParent?: boolean | undefined; checkStrictly?: boolean | undefined; ... 54 more ...; treeData: DataNode[]; }' is not assignable to type 'Omit<Omit<Pick<TreeProps<DataNode | BasicDataNode> & { children?: ReactNode; } & { ref?: Ref<Tree<DataNode>> | undefined; }, "ref"> & Partial<...> & Partial<...>, never> & Partial<...>, "theme">'.
      Types of property 'onSelect' are incompatible.
        Type '((selectedKeys: Key[], info: { event: "select"; selected: boolean; node: EventDataNode; selectedNodes: DataNode[]; nativeEvent: MouseEvent; }) => void) | undefined' is not assignable to type '((selectedKeys: Key[], info: { event: "select"; selected: boolean; node: EventDataNode; selectedNodes: (DataNode | BasicDataNode)[]; nativeEvent: MouseEvent; }) => void) | undefined'.
          Type '(selectedKeys: Key[], info: { event: "select"; selected: boolean; node: EventDataNode; selectedNodes: DataNode[]; nativeEvent: MouseEvent; }) => void' is not assignable to type '(selectedKeys: Key[], info: { event: "select"; selected: boolean; node: EventDataNode; selectedNodes: (DataNode | BasicDataNode)[]; nativeEvent: MouseEvent; }) => void'.
            Types of parameters 'info' and 'info' are incompatible.
              Type '{ event: "select"; selected: boolean; node: EventDataNode; selectedNodes: (DataNode | BasicDataNode)[]; nativeEvent: MouseEvent; }' is not assignable to type '{ event: "select"; selected: boolean; node: EventDataNode; selectedNodes: DataNode[]; nativeEvent: MouseEvent; }'.
                Types of property 'selectedNodes' are incompatible.
                  Type '(DataNode | BasicDataNode)[]' is not assignable to type 'DataNode[]'.
                    Type 'DataNode | BasicDataNode' is not assignable to type 'DataNode'.
                      Property 'key' is missing in type 'BasicDataNode' but required in type 'DataNode'.
  Overload 2 of 2, '(props: StyledComponentPropsWithAs<CompoundedComponent, DefaultTheme, {}, never, CompoundedComponent, CompoundedComponent>): ReactElement<...>', gave the following error.
    Type '{ showLine?: boolean | { showLeafIcon: boolean; } | undefined; className?: string | undefined; multiple?: boolean | undefined; autoExpandParent?: boolean | undefined; checkStrictly?: boolean | undefined; ... 54 more ...; treeData: DataNode[]; }' is not assignable to type 'Omit<Omit<Pick<TreeProps<DataNode | BasicDataNode> & { children?: ReactNode; } & { ref?: Ref<Tree<DataNode>> | undefined; }, "ref"> & Partial<...> & Partial<...>, never> & Partial<...>, "theme">'.
      Types of property 'onSelect' are incompatible.
        Type '((selectedKeys: Key[], info: { event: "select"; selected: boolean; node: EventDataNode; selectedNodes: DataNode[]; nativeEvent: MouseEvent; }) => void) | undefined' is not assignable to type '((selectedKeys: Key[], info: { event: "select"; selected: boolean; node: EventDataNode; selectedNodes: (DataNode | BasicDataNode)[]; nativeEvent: MouseEvent; }) => void) | undefined'.  TS2769

    25 |         treeData &&
    26 |         (treeData.length ? (
  > 27 |           <StyledDirectoryTree
       |            ^
    28 |             showIcon
    29 |             blockNode
    30 |             treeData={treeData}

报错显示,主要是这个文件? frontend/src/app/components/Tree/index.tsx(27,12)

scottsut commented 2 years ago

我本地重新安装依赖没能复现问题,请提供以下信息帮助我们定位:

  1. 操作系统
  2. nodejs 版本
  3. 使用的包管理工具及版本
  4. typescript 版本

另外,可以将报错的参数加上 as any 临时解决问题

feature09 commented 2 years ago

我本地重新安装依赖没能复现问题,请提供以下信息帮助我们定位:

  1. 操作系统
  2. nodejs 版本
  3. 使用的包管理工具及版本
  4. typescript 版本

另外,可以将报错的参数加上 as any 临时解决问题

win10
D:\data\datart\datart-1.0.0-alpha.3\frontend>node --version
v16.13.0

第三个不太清楚是不是这个意思:

D:\data\datart\datart-1.0.0-alpha.3\frontend>npm --version
8.1.0
D:\data\datart\datart-1.0.0-alpha.3\frontend>npm view typescript version
4.5.2

这个错误就是npm start的时候报的。

feature09 commented 2 years ago

我降低了一些包的版本

npm install typescript@4.2.2
npm install antd@4.16.13
npm @craco/craco@6.4.0

接着报了一个错误:

D:/data/datart/datart-1.0.0-alpha.3/frontend/src/app/pages/MainPage/pages/SourcePage/SourceDetailPage/ConfigComponent/index.tsx
TypeScript error in D:/data/datart/datart-1.0.0-alpha.3/frontend/src/app/pages/MainPage/pages/SourcePage/SourceDetailPage/ConfigComponent/index.tsx(193,7):
Type 'import("D:/data/datart/datart-1.0.0-alpha.3/frontend/node_modules/rc-field-form/lib/interface").Rule[]' is not assignable to type 'import("D:/data/datart/datart-1.0.0-alpha.3/frontend/node_modules/antd/node_modules/rc-field-form/lib/interface").Rule[]'.
  Type 'import("D:/data/datart/datart-1.0.0-alpha.3/frontend/node_modules/rc-field-form/lib/interface").Rule' is not assignable to type 'import("D:/data/datart/datart-1.0.0-alpha.3/frontend/node_modules/antd/node_modules/rc-field-form/lib/interface").Rule'.
    Type 'RuleRender' is not assignable to type 'Rule'.
      Type 'import("D:/data/datart/datart-1.0.0-alpha.3/frontend/node_modules/rc-field-form/lib/interface").RuleRender' is not assignable to type 'import("D:/data/datart/datart-1.0.0-alpha.3/frontend/node_modules/antd/node_modules/rc-field-form/lib/interface").RuleRender'.
        Types of parameters 'form' and 'form' are incompatible.
          Property 'getFieldWarning' is missing in type 'import("D:/data/datart/datart-1.0.0-alpha.3/frontend/node_modules/antd/node_modules/rc-field-form/lib/interface").FormInstance<any>' but required in type 'import("D:/data/datart/datart-1.0.0-alpha.3/frontend/node_modules/rc-field-form/lib/interface").FormInstance<any>'.  TS2322

    191 |       initialValue={defaultValue}
    192 |       extra={description}
  > 193 |       rules={rules}
        |       ^
    194 |       {...extraFormItemProps}
    195 |     >
    196 |       {component}

我就把对应文件所引的包替换了。

// import { Rule } from 'rc-field-form/lib/interface';
import { Rule } from 'antd/node_modules/rc-field-form/lib/interface';

目前看是跑起来了。。。

haosusu commented 2 years ago

一样的报错

Plortinus commented 1 year ago

antd里的rc-field-form版本是1.20.0, "@ant-design/pro-table": "2.60.1"里的rc-field-form版本是1.37.0,两个版本不一样导致的