Does Typescript support “subset types”?

后端 未结 7 1776
青春惊慌失措
青春惊慌失措 2020-12-29 02:36

Let\'s say I have an interface:

interface IUser {
  email: string;
  id: number;
  phone: string;
};

Then I have a function that expects a

7条回答
  •  误落风尘
    2020-12-29 02:54

    proper solution with mapped types:

    updateUser(userData: {[P in K]: IUser[P]}) {
        ...
    }
    

提交回复
热议问题