Last active
May 31, 2022 17:02
-
-
Save vko-online/5cd38dab473e70886bc6d59bb6bce59a to your computer and use it in GitHub Desktop.
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
/*interface BarData { | |
day1: number; | |
day2: number; | |
... | |
day30: number; | |
}*/ | |
type LessThan<N extends number, A extends number[] = []> = | |
N extends A['length'] ? A[number] : LessThan<N, [...A, A['length']]>; | |
type OneToThirty = Exclude<LessThan<31>, 0>; | |
interface BarData extends Record<`day${OneToThirty}`, number> { } | |
function foo(bar: BarData) { | |
bar.day14 = 3; | |
bar.day100 = 1 | |
} |
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
test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment