Created
June 8, 2022 07:12
-
-
Save MikelArnaiz/f2780225c2c9cb199365b4daf960bfad to your computer and use it in GitHub Desktop.
ts-pattern v3 bug
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
type Foo = | |
| "Nope" | |
| ["a", "b", "c", "d", 'e', { x: string }] | |
function fn(foo: Foo) { | |
return match<Foo, string>(foo) | |
.with('Nope', () => 'no') | |
.with(['a', 'b', 'c', 'd', 'e', __], () => 'yes') | |
.exhaustive() | |
} | |
No overload matches this call. | |
Overload 1 of 4, '(pattern: Pattern<Foo>, handler: (selections: SeveralAnonymousSelectError<"You can only use a single anonymous selection (with `select()`) in your pattern. If you need to select multiple values, give them names with `select(<name>)` instead">, value: Foo) => string): Match<...>', gave the following error. | |
Type 'GuardPattern<unknown, unknown> & { string: GuardPattern<unknown, string>; number: GuardPattern<unknown, number>; NaN: GuardPattern<unknown, never>; boolean: GuardPattern<...>; nullish: GuardPattern<...>; }' is not assignable to type 'undefined'. | |
Overload 2 of 4, '(...args: [Pattern<Foo>, ...Pattern<Foo>[], (value: Foo | ({ x: string; } | "a" | "b" | "c" | "d" | "e")[]) => string]): Match<Foo, string, ["Nope", "Nope"] | ... 9 more ... | [...], unknown>', gave the following error. | |
Type 'GuardPattern<unknown, unknown> & { string: GuardPattern<unknown, string>; number: GuardPattern<unknown, number>; NaN: GuardPattern<unknown, never>; boolean: GuardPattern<...>; nullish: GuardPattern<...>; }' is not assignable to type 'undefined'. |
Author
MikelArnaiz
commented
Jun 8, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment