我们的结构如下:
export type LinkRestSource = {
model: string;
rel?: string;
title?: string;
} | {
model?: string;
rel: string;
title?: string;
} | {
model?: string;
rel?: string;
title: string;
};
Run Code Online (Sandbox Code Playgroud)
这几乎与说法相同
type LinkRestSource = Partial<{model: string, rel: string, title: string}>
Run Code Online (Sandbox Code Playgroud)
除了这将允许传入空对象,而初始类型需要传递其中一个属性
我怎样才能创建类似的泛型Partial,但其行为与上面的结构相似?