Created
February 7, 2025 14:42
-
-
Save Kcko/69694abda54f0eb607867608c3eaf18e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Omit je utility typ v TypeScriptu, který umožňuje vytvořit nový typ s vynechanými (omitted) klíči z původního typu. To znamená, že nový typ bude obsahovat všechny vlastnosti z původního typu kromě těch, | |
které explicitně specifikujete k vynechání | |
Omit<T, K> | |
*/ | |
// 1 | |
interface User { | |
id: number; | |
name: string; | |
email: string; | |
password: string; | |
} | |
type PublicUser = Omit<User, 'password'>; // nebo Omit<User, 'password' | 'id'> | |
const user: PublicUser = { | |
id: 1, | |
name: 'Alice', | |
email: '[email protected]', | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment