Skip to content

fix: use iterables instead of generators#2213

Merged
kettanaito merged 3 commits intomswjs:fix/generator-resolverfrom
jakebailey:fix/generator-resolver-2
Jul 21, 2024
Merged

fix: use iterables instead of generators#2213
kettanaito merged 3 commits intomswjs:fix/generator-resolverfrom
jakebailey:fix/generator-resolver-2

Conversation

@jakebailey
Copy link
Contributor

@jakebailey jakebailey commented Jul 21, 2024

This applies #2108 (comment) to the fix/generator-resolver branch.

Best viewed without whitespace: https://github.com/mswjs/msw/pull/2213/files?w=1

return result
}
this.resolverGenerator =
Symbol.iterator in result
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reflect.has (used in isIterable) is the same operation as in, except that TS can acutally narrow using in.

@@ -1,11 +1,20 @@
// Redefine these types; the three-parameter forms are only available in TypeScript 5.6 or later.
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for putting this in! Exactly what I was wondering about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can also make these JSDoc comments so they're carried down; whatever you'd prefer.

Copy link
Member

Choose a reason for hiding this comment

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

I'd mark them as @todo to remove these types once TS 5.6 is the minimal supported version. Not going to happen any time soon but still.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@kettanaito
Copy link
Member

😱

Screenshot 2024-07-21 at 19 35 24

Copy link
Member

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

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

This looks incredible! 🎉 Thank you so much, @jakebailey. You've made the impossible possible. Local tests are passing, type-compatibility on CI is green.

@kettanaito kettanaito merged commit 63fdd4b into mswjs:fix/generator-resolver Jul 21, 2024
@jakebailey jakebailey deleted the fix/generator-resolver-2 branch July 21, 2024 22:28
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.

2 participants