Table components align Type 'string' is not assignable to type '"right" | "left" | "center" | undefined'.
const columns = [
title: '排行',
dataIndex: 'goods_id',
width: '15%',
align: 'center',
render: (val, record, index) => {
index = 1;
let className = '';
switch (index) {
case 1:
className = 'first';
break;
case 2:
className = 'second';
break;
case 3:
className = 'third';
return (<span className={className}>{index}</span>);
title: '商品名称',
dataIndex: 'goods_name',
width: '70%'
title: '销量',
dataIndex: 'sales',
width: '15%',
align: 'center',
render: (val, record, index) => {
index = 1;
let className = '';
switch (index) {
case 1:
className = 'first';
break;
case 2:
className = 'second';
break;
case 3:
className = 'third';
return (<span className={className}>{val}</span>);
const data = [
goods_id: 1,
goods_name: '陕西眉县徐香绿心猕猴桃',
sales: 108
goods_id: 2,
goods_name: '山东沾化冬枣 精品果',
sales: 99
goods_id: 3,
goods_name: '四川当季爱媛38号果冻橙 可以吸的新鲜水果',
sales: 71
What is expected?
typescript 不警告报错
What is actually happening?
Type '{ title: string; dataIndex: string; width: string; align: string; render: (val: any, record: any, index: any) => Element; } | { title: string; dataIndex: string; width: string; align?: undefined; render?: undefined; }' is not assignable to type 'ColumnGroupType<{ goods_id: number; goods_name: string; sales: number; }> | ColumnType<{ goods_id: number; goods_name: string; sales: number; }>'.
Type '{ title: string; dataIndex: string; width: string; align: string; render: (val: any, record: any, index: any) => Element; }' is not assignable to type 'ColumnGroupType<{ goods_id: number; goods_name: string; sales: number; }> | ColumnType<{ goods_id: number; goods_name: string; sales: number; }>'.
Type '{ title: string; dataIndex: string; width: string; align: string; render: (val: any, record: any, index: any) => Element; }' is not assignable to type 'ColumnType<{ goods_id: number; goods_name: string; sales: number; }>'.
Types of property 'align' are incompatible.
Type 'string' is not assignable to type '"left" | "center" | "right" | undefined'.
如果对cloumns 强制 any 又背离了初衷。JS版本不会报,ts版本会报!演示地址是js版本。跟我本地代码一致的!
Environment
help wanted
The suggestion or request has been accepted, we need you to help us by sending a pull request.
label
Nov 10, 2020
help wanted
The suggestion or request has been accepted, we need you to help us by sending a pull request.
label
Nov 10, 2020