-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve types of test.each #840
Conversation
✔️ Deploy Preview for vitest-dev ready! 🔨 Explore the source changes: dadb2a8 🔍 Inspect the deploy log: https://app.netlify.com/sites/vitest-dev/deploys/6216451d537e500008aecd2d 😎 Browse the preview: https://deploy-preview-840--vitest-dev.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes:
suite.each = <T>(cases: T[] | readonly T[]) => { | ||
return (name: string, fn: (...args: T extends any[] | readonly any[] ? MutableArray<T> : [T]) => void) => { | ||
suite.each = <T>(cases: ReadonlyArray<T>) => { | ||
return (name: string, fn: (...args: T[]) => void) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the changes; the rest are caused by linting!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you disable prettier and make the PR only about the code changes? Thanks.
name: string, | ||
fn: (...args: T[]) => void | ||
) => void | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plus this!
expect(typedA).toBeDefined() | ||
expect(typedB).toBeDefined() | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this!
const test = createChainable( | ||
['concurrent', 'skip', 'only', 'todo', 'fails'], | ||
fn, | ||
) as TestAPI | ||
|
||
test.each = <T>(cases: T[] | readonly T[]) => { | ||
return (name: string, fn: (...args: T extends any[] | readonly any[] ? MutableArray<T> : [T]) => void) => { | ||
test.each = <T>(cases: ReadonlyArray<T>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this!
Fixes #811