ant-design / ant-design/pro-components
🧐[问题]自定义了valueType,怎么修改ts定义,才能不报错
- Dominant language
- TypeScript
- Stars
- 4.8k
- Forks
- 1.4k
- Avg merge
- 10h 44m
- Merged PRs (30d)
- 3
Description
提问前先看看:
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md
### 🧐 问题描述
使用了umi和pro-components
我自定义了valueType,但是发现ts无法通过
### 💻 示例代码
```
const valueTypeMap: Record = {
lookup: {
renderFormItem(text, props) {
return
}
},
}
export default function Layout() {
return (
);
}
export const columns: ProColumns[] = [
{
title: '机型编码',
dataIndex: 'no',
width: 120,
tooltip: '机型编码是唯一的 key',
formItemProps: {
rules: [{ required: true, whitespace: true }],
},
render(dom, entity, index, action, schema) {
console.log(dom, entity, index, action, schema);
return {dom};
},
},
{
title: '机型名称',
dataIndex: 'name',
valueType: 'lookup', // 这一行会报错
width: 120,
fieldProps: {
allowClear: true,
},
formItemProps: {
rules: [{ required: true, whitespace: true }],
},
},
];
```
我尝试过了给ProColumns的第二个泛型参数传递'lookup',但是我在fieldProps的定义中还是会遇到麻烦,它不是我自定义的类型定义
### 🚑 其他信息
Contributor guide
Research direction
Start by tracing the TypeScript definitions for ProConfigProvider's valueTypeMap, ProColumns, and fieldProps, using the custom lookup example as the reproduction. Determine how a custom valueType should be accepted while preserving fieldProps typing, then verify that the example type-checks without errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100