接口与类型
type与interface
内置的语法糖
Partial和Required
Partial将传入的属性变为可选
type Oc= Partial
type Partial<T> = {
[P in keyof T]?: T[P];
}
Required 将传入的属性变为必选
type Oc= Required
type Required<T> = { [P in keyof T]-?: T[P] };
Readonly
Readonly将传入的属性变为只读
type Oc= Partial<IProps>
type Readonly<T> = {
readonly [P in keyof T]: T[P];
}
Omit
Exclude (继承)
interface Point {
x: number;
y: number;
}