Get the App
SLTechnology News&Howtos  ›  Development  › 

How TypeScript uses Omit

Shulou Source: shulou.com Published: 2022-06-01 04:17:56 11月15日 Update

This article mainly introduces TypeScript how to use Omit, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Skillful use of Omit

Sometimes we need to reuse a type, but we don't need all the attributes within that type, so we need to eliminate some attributes, so Omit comes in handy.

Interface User {username: string id: number token: string avatar: string role: string} type UserWithoutToken = Omit

This method is often used in React. When the parent component passes data down through props, it usually needs to reuse the props type of the parent component, but it also needs to eliminate some useless types.

Thank you for reading this article carefully. I hope the article "how to use Omit in TypeScript" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Articles types properties time components reuse value interests at the same time data methods more sometimes friends use knowledge editing industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Information NVidia macOS Microsoft