Created
December 1, 2023 10:35
-
-
Save sseletskyy/f3b9b2b4d8a27af56c3e9478f63c4a67 to your computer and use it in GitHub Desktop.
Typescript ModifyProps
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
type OriginalType = { | |
prop1: string; | |
prop2: number; | |
prop3: boolean; | |
}; | |
type ModifyProp<Type, Key extends keyof Type, Value> = Omit<Type, Key> & { | |
[K in Key]: Value; | |
}; | |
type AlternativeType = ModifyProp<OriginalType, 'prop2', string>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment