fix flow typing of mockComponent#53739
Closed
panagosg7 wants to merge 1 commit into
Closed
Conversation
Summary: The previous condition `typeof isESModule extends true` in the definition of `mockComponent` is always `true` (this is expected by semantics of conditional types). See [try-Flow](https://flow.org/try/#1N4Igxg9gdgZglgcxALlAIwIZoKYBsD6uEEAztvhgE6UYCe+JADpdhgCYowa5kA0I2KAFcAtiRQAXSkOz9sADwxgJ+NPTbYuQ3BMnTZA+Y2yU4IwRO4A6SFBIrGVDGM7c+h46fNRLuKxJIGWh8MeT0ZfhYlCStpHzNsFBAMIQkIEQwJODAQfiEyfBE4eWw2fDgofDBMsAALfAA3KjgsXGxxZC4eAw0G-GhcWn9aY3wWZldu-g1mbGqJUoBaCRHEzrcDEgBrbAk62kXhXFxJ923d-cPRHEpTgyEoMDaqZdW7vKgoOfaSKgOKpqmDA+d4gB5fMA-P6LCCMLLQbiLOoYCqgh6-GDYRYIXYLSgkRZkCR4jpddwPfJLZjpOBkUEKTwJEJ+DAkMiUFSwkyZCC3dbdAC+-EgGiSAB1YA9lHBoAACXmICrcAAUAEpZcAJbLtbKYFL4VBdVBlWhkLK0MRnlBVWaVsYIDBzbKFAsoGwSLKpDJZQB+WUARllZoATBrZSwJEJKIbgwBuWUCiVanW2eyy+SBgC8RuVXuwqvjAHpC7LM2XZcHk9qM7LWQGiyWTJReVX04G63Gk4aU9A0-JQ9mYMayfmG6Xy5Xu9XQ3X-WOmy2p+mZx7O1BE1AuxK9Y8DbriqU1RrWzvpXKhwAeABCZotECtAD4TWarzbZVfnfJXe7PfpfQGgwrMMIyjQ1lQABlrD1gVoAtZULAAqWUHjtVg0DaWUEJLDdW1TCQ21LHM8zg4tx2zf1WxrWdY0o9tV3nahF1w3t8P7Qih2VEcSJLMts0nHVlyg+t4MbRjKEolcK3jCUBVyEAGhMEgZSgJIGnAqxgwADn9KxwJAAUgA) A bug in Flow made it so that when this type was exported `typeof isESModule` became `any`, which made it so that the conditional always evaluated to the first part. The bug is fixed in D82193099. This diff uses a type parameter, which can be correctly instantiated at the call site. Changelog: [internal] Differential Revision: D82226987
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D82226987 |
Contributor
|
This pull request has been merged in 3d4f0f4. |
Collaborator
|
This pull request was successfully merged by @panagosg7 in 3d4f0f4 When will my fix make it into a release? | How to file a pick request? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
The previous condition
typeof isESModule extends truein the definition ofmockComponentis alwaystrue(this is expected by semantics of conditional types).See try-Flow
A bug in Flow made it so that when this type was exported
typeof isESModulebecameany, which made it so that the conditional always evaluated to the first part. The bug is fixed in D82193099.This diff uses a type parameter, which can be correctly instantiated at the call site.
Changelog: [internal]
Differential Revision: D82226987