TS类型体操

发表于:2023-10-10 17:57技术,ts热度:24喜欢:0

常用类型记录

提取对象的keys作为另外一个固定类型对象的可选keys

常用语从data字段提取出keys,作为rules字段

import type { FormItemRules } from 'element-plus'

interface A {
  name:string
  id:string
  label?:value
}

type Partial <O={},V=any>  =  Partial<Record<keyof O,V>>

type ARules = Partial<A,FormItemRules| FormItemRules[]>