0%

用ts构建长属性列表

解决方案

1
2
3
4
5
type Fields<Count = 0, Props extends string[] = []> = Props['length'] extends Count ? Props[number]: Fields<Count, [...Props, `ad_${Props['length']}`]>;

type SensorInfo ={
[K in Fields<31>]: number;
}