39 items
Partial Update With Omit
Code QuizChoosing the Right Utility Type
QuizUtility Types, Enums & Strictness
Slides / VideoUtility Types, Enums & Strictness
FlashcardGenerics, Unions & Utility Types
Slides / VideoGenerics, Unions & Utility Types
FlashcardBuilding Custom Utility Types
Slides / VideoExclude and Extract Distribute Over Unions
Slides / VideoComposing Multiple Utility Types
Slides / VideoUtility Types Built From Type Operators
Slides / VideoString Manipulation Utility Types
Slides / VideoAwaited<T> Unwraps Promise Types
Slides / VideoThisParameterType and OmitThisParameter
Slides / VideoInstanceType<T> Extracts Instance Types
Slides / VideoConstructorParameters<T> Extracts Constructor Args
Slides / VideoParameters<T> Extracts Argument Types
Slides / VideoReturnType<T> Extracts Return Types
Slides / VideoNonNullable<T> Strips Null and Undefined
Slides / VideoExtract<T, U> Keeps Matching Union Members
Slides / VideoExclude<T, U> Removes Union Members
Slides / VideoOmit<T, K> Excludes Properties
Slides / VideoPick<T, K> Selects a Subset
Slides / VideoRecord<K, T> Maps Keys to Values
Slides / VideoReadonly<T> Locks Every Property
Slides / VideoRequired<T> Makes Properties Required
Slides / VideoPartial<T> Makes Properties Optional
Slides / VideoRecord with Union Keys
Code QuizPartial and Required Modifiers
Code QuizComposing utility types
QuizHomomorphic modifier preservation
QuizImplementing utility types
QuizDeep Partial and Readonly
QuizRecord with literal key sets
QuizPick/Omit with index signatures
QuizUtility types over unions
QuizConstructorParameters basics
QuizThisParameterType and OmitThisParameter
QuizThisType for contextual this
QuizOmit vs Exclude semantics
QuizPartial Update With Omit
Spot why a partial user update fails to type-check when using Omit.
interface User {
id: number;
name: string;
email: string;
}
type UserUpdate = Omit<User, "id">;
function updateUser(id: number, changes: UserUpdate) {
// apply changes to the user with the given id...
}
// Intended: update only the name
updateUser(1, { name: "Alice" }); // Error!Why does the updateUser call fail to type-check, and how should UserUpdate be fixed?