Skip to content

Instantly share code, notes, and snippets.

@sseletskyy
Created December 1, 2023 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sseletskyy/f3b9b2b4d8a27af56c3e9478f63c4a67 to your computer and use it in GitHub Desktop.
Save sseletskyy/f3b9b2b4d8a27af56c3e9478f63c4a67 to your computer and use it in GitHub Desktop.
Typescript ModifyProps
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