## 事象 こんな感じのコードを書くと.. ```ts import { count, intersection } from "./collection-helper"; import { describe, expect, test } from "@jest/globals"; describe.each` values | expected ${["aa", "ii", "aa"]} | ${{ aa: 2, ii: 1 }} `("count", ({ values, expected }) => { test(`count(${values}) = ${expected}`, () => { expect(count(values)).toStrictEqual(expected); }); }); ``` `expect(count(values))`の`values`がエラーになる。 ``` TS2345: Argument of type 'string[] | { aa: number; ii: number; }' is not assignable to parameter of type 'string[]'.   Type '{ aa: number; ii: number; }' is missing the following properties from type 'string[]': length, pop, push, concat, and 35 more. ``` [[Jest]]のバージョンは`28.1.3`。バージョン`29.0.3`でも再現する。 ## 原因 [[template literalを使った.each (Jest)|template literalを使った.each]]には[[型引数 (TypeScript)|型引数]]の指定が必要だから。 ## 解決方法 `.each`のあとに以下のように[[型引数 (TypeScript)|型引数]]を指定する。 ```ts test.each<{v1: number, v2: string}>` v1 | v2 ${1} | ${"1"} ${2} | ${"2"} ` ``` ## 参考 - [全体 · Jest](https://jestjs.io/ja/docs/api#template-literal)