Repository navigation
Fix Flow types that use void for a missing value - #60206
Open
SamChou19815 wants to merge 1 commit into
Open
SamChou19815 wants to merge 1 commit into
SamChou19815 wants to merge 1 commit into
Conversation
Summary: Under Flow's `experimental.ts_void`, `void` is TypeScript's `void`, which flows only into `void`, `any` and `unknown`, so a value typed `void` can't be passed where an optional value or `undefined` is expected. This updates React Native's Flow types for projects that check React Native's sources with that option: - Library definitions say `undefined` where the TypeScript definitions do: `babel/traverse`'s `Scope#getBinding()` and `child_process.spawnSync()`'s `error`. execa's `env` is read-only, so it accepts both `process.env` and objects with `void` values. - `BackHandler` handlers and the RN tester's stall handler may return nothing. - `EventTarget`'s listener maps and codegen's `bubblingType` use maybe types instead of `void`, `componentDidMount()` in `TouchableNativeFeedback` returns `void`, and two RN tester components that render nothing return `undefined`. - Where the only fix needs the `undefined` type, which this repository's Flow config doesn't enable, the error is suppressed. Without that option, `void` and `undefined` are the same type, so nothing changes. Changelog: [General][Changed] - Allow `BackHandler` event listeners to return nothing [General][Changed] - Type `TouchableNativeFeedback`'s `componentDidMount()` as returning `void` Differential Revision: D133660807
|
@SamChou19815 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D133660807. |
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
This branch has not been deployed
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:
Under Flow's
experimental.ts_void,voidis TypeScript'svoid, which flows only intovoid,anyandunknown, so a value typedvoidcan't be passed where an optional value orundefinedis expected. This updates React Native's Flow types for projects that check React Native's sources with that option:undefinedwhere the TypeScript definitions do:babel/traverse'sScope#getBinding()andchild_process.spawnSync()'serror. execa'senvis read-only, so it accepts bothprocess.envand objects withvoidvalues.BackHandlerhandlers and the RN tester's stall handler may return nothing.EventTarget's listener maps and codegen'sbubblingTypeuse maybe types instead ofvoid,componentDidMount()inTouchableNativeFeedbackreturnsvoid, and two RN tester components that render nothing returnundefined.undefinedtype, which this repository's Flow config doesn't enable, the error is suppressed.Without that option,
voidandundefinedare the same type, so nothing changes.Changelog:
[General][Changed] - Allow
BackHandlerevent listeners to return nothing[General][Changed] - Type
TouchableNativeFeedback'scomponentDidMount()as returningvoidDifferential Revision: D133660807