nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: true-myth/true-myth
Pull request #1005 (2025-04-09 17:24:59)

Task: `withRetries` is callable with any `Strategy`
Okay, but for real this time. Lesson (re)learned: Always, always, *always* add the breaking test first.


Patch:
diff --git a/src/task.ts b/src/task.ts
index 239641b..209715d 100644
--- a/src/task.ts
+++ b/src/task.ts
@@ -2263,7 +2263,7 @@ function identity<T>(value: T): T {
  */
 export function withRetries<T, E>(
   retryable: (status: RetryStatus) => Task<T, E | StopRetrying> | StopRetrying,
-  strategy: IterableIterator<number> = (function* () {
+  strategy: delay.Strategy = (function* () {
     for (let i = 0; i < 3; i++) {
       yield 0;
     }


Test patch:
diff --git a/test/task.test.ts b/test/task.test.ts
index aba2648..960939f 100644
--- a/test/task.test.ts
+++ b/test/task.test.ts
@@ -48,6 +48,7 @@ import {
   jitter,
   linear,
   none,
+  type Strategy,
 } from 'true-myth/task/delay';
 import Maybe from 'true-myth/maybe';
 import Result from 'true-myth/result';
@@ -2861,6 +2862,12 @@ describe('module-scope functions', () => {
         );
       });
     });
+
+    test('type checks when explicitly passed a `Strategy`', () => {
+      let retryable = () => new Task(() => {});
+      let strategy = function* (): Strategy {};
+      expectTypeOf(withRetries).toBeCallableWith(retryable, strategy());
+    });
   });
 
   describe('delays', () => {