You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Been playing with this as I like the simplicity of your approach.
Whenever I use otherwise Jest tests covering that code break. Minimal example in the existing index.spec.ts:
it("using `otherwise` allows `run` in cases where `when`s are not exhaustive",()=>{constmatcher=match(3asnumber|string).when(isString,(_)=>"it is string").otherwise(()=>'no case matched, resulting to default')type_=Expect<Equal<typeofmatcher,BuiltMatch<string>>>;expect(matcher.run()).toBe('no case matched, resulting to default')})
This results in the following failure:
● match › using `otherwise` allows `run`in cases where `when`s are not exhaustive
TypeError: Cannot read property 'run' of undefined
39 |
40 |type _ = Expect<Equal<typeof matcher, BuiltMatch<string>>>;> 41 |expect(matcher.run()).toBe('no case matched, resulting to default')
| ^
42 | })
43 | });
44 |
at Object.<anonymous> (test/index.spec.ts:41:20)
Commit of this as a skipped test available on my fork.
If you have any ideas how to tackle this I'm happy to tinker and prepare a PR. Currently I'm out of ideas.
The text was updated successfully, but these errors were encountered:
Been playing with this as I like the simplicity of your approach.
Whenever I use
otherwise
Jest tests covering that code break. Minimal example in the existingindex.spec.ts
:This results in the following failure:
Commit of this as a skipped test available on my fork.
If you have any ideas how to tackle this I'm happy to tinker and prepare a PR. Currently I'm out of ideas.
The text was updated successfully, but these errors were encountered: