How to create a Partial-like that requires a single property to be set

后端 未结 5 1210
春和景丽
春和景丽 2020-11-29 03:24

We have a structure that is like the following:

export type LinkRestSource = {
    model: string;
    rel?: string;
    title?: string;
} | {
    model?: str         


        
5条回答
  •  情话喂你
    2020-11-29 04:09

    There's another solution if you know which properties you want.

    AtLeast = Partial & Pick
    

    This would also allow you to lock in multiple keys of a type, e.g. AtLeast.

提交回复
热议问题