Skip to content
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

Merged
merged 4 commits into from
Feb 23, 2022
Merged

fix: improve types of test.each #840

merged 4 commits into from
Feb 23, 2022

Conversation

Aslemammad
Copy link
Member

Fixes #811

@netlify
Copy link

netlify bot commented Feb 23, 2022

✔️ 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

Copy link
Member Author

@Aslemammad Aslemammad left a 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) => {
Copy link
Member Author

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!

Copy link
Member

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
}
Copy link
Member Author

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()
})

Copy link
Member Author

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>) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this!

@antfu antfu changed the title fix: Incorrect typing of test.each output fix: improve types of test.each Feb 23, 2022
@antfu antfu merged commit c161a44 into vitest-dev:main Feb 23, 2022
@Aslemammad Aslemammad deleted the fix/811 branch February 23, 2022 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect typing of test.each output
2 participants