Created
January 21, 2023 12:31
-
-
Save warrenday/37fed0fa3320b273ef18cbcaed0d8976 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
| function positionalProp< | |
| N extends string, F extends boolean | string | number | |
| >(name: N, fallback?: F): ( | |
| F extends false ? | |
| string | number | false | |
| : F extends string ? string : number | |
| ) | |
| const x = positionalProp('foo', false) // string | number | false | |
| const x2 = positionalProp('foo', 'hello') // string | |
| const x3 = positionalProp('foo', 2) // number |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment