Skip to content

Conversation

@9aoy
Copy link
Contributor

@9aoy 9aoy commented Oct 27, 2025

Summary

fix type error when each template type is primitive.

expect:
image

actual:
image

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings October 27, 2025 12:44
@netlify
Copy link

netlify bot commented Oct 27, 2025

Deploy Preview for rstest-dev ready!

Name Link
🔨 Latest commit 29df394
🔍 Latest deploy log https://app.netlify.com/projects/rstest-dev/deploys/68ff6931518eb400089e73a8
😎 Deploy Preview https://deploy-preview-653--rstest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a TypeScript type error that occurs when using the each template with primitive types. The fix adds a new overload signature to TestEachFn that handles arrays of primitive values, ensuring proper type inference when the array elements themselves are the test parameters rather than tuples.

Key Changes:

  • Added a new function overload to TestEachFn interface for handling primitive type arrays
  • Added test case to verify the fix works with primitive number arrays

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/types/api.ts Adds new overload signature to support primitive type arrays in TestEachFn
e2e/test-api/each.test.ts Adds test case demonstrating the fix with a primitive number array

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cases: readonly T[],
): (
description: string,
fn: (...args: T[]) => MaybePromise<void>,
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The parameter type T[] creates an array of T instead of spreading T as individual parameters. For primitive types, this should be (arg: T) or use conditional types. With the current signature, when T is number, the function expects (...args: number[]) which means any number of number arguments, not a single number argument as intended.

Suggested change
fn: (...args: T[]) => MaybePromise<void>,
fn?: (param: T) => MaybePromise<void>,

Copilot uses AI. Check for mistakes.
@9aoy 9aoy merged commit 1a32ac4 into main Oct 28, 2025
17 checks passed
@9aoy 9aoy deleted the each-type branch October 28, 2025 03:02
@9aoy 9aoy mentioned this pull request Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants