typescript实现类型推算
在代码中我们需要实现condition和examineState这两个类型可填,我们也可以通过这种方式去实现 但是在字段很多而且在应用场景很多的时候这样写很麻烦也可能你这个地方需要必填另外一个地方不需要必填这样就造成了全局很多的重复代码。而且也不便于维护。
export type ContractParams = {
current: number;
pageSize: number;
phone: string;
condition?: string;
examineState?: string;
};
我们可以通过Omit
export type ContractParams = {
current: number;
pageSize: number;
phone: string;
condition: string;
examineState: string;
};
type Optional
export type ContractIteme = Optional
精彩文章
发表评论