Last active
July 31, 2023 21:58
-
-
Save erassynathingo/6bce4e97ded5a1704798e2dd505d897b 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
export type Letters = 'a' | 'b' | 'c'; | |
type RemoveC<TType> = TType extends 'c' ? never : TType; | |
type WithoutC = RemoveC<Letters>; | |
// Without C is not of type 'a' | 'b' | |
// We can return different mebers of the type or manipulate them. Returning never removes the element | |
// You can replace never with anything e.g. 'd' which means typeWithoutC will now be equal to 'a' | 'b' | 'd' | |
// This can be applied to enums too |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment