Created
June 9, 2021 16:16
-
-
Save tvler/e1f3cd188dc1b8f680b496fbae4d74ce to your computer and use it in GitHub Desktop.
A way to test if a Type adheres to a wider Supertype, without widening the initial Type
This file contains hidden or 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 Guard<Type extends SuperType, SuperType> = Type; | |
const tuple = [1, 2, 3] as const; | |
type Test = Guard<typeof tuple, ReadonlyArray<number>>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment