Skip to content

Commit 5928144

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Fix TS Type for measureLayout optional parameter
Summary: Encountered this, causing typechecking to fail on an example in the current RN documentation. `onFail` is an optional parameter (see https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-native-renderer/src/ReactNativeTypes.js#L106), which is not optional in current TS types. Update the TS typings to match. Note that "?" here is positioned to be a Flow optional parameter, instead of a maybe type. Which means it accepts undefined, but not null, matching the TS usage of "?" which always means possibly undefined (but never null, like a flow maybe type allows). Changelog: [General][Fixed] - Fix TS Type for measureLayout optional parameter Reviewed By: lunaleaps Differential Revision: D41775900 fbshipit-source-id: 8f53428b8077ec9139c7c1bbc60ed20f5fa9f7ea
1 parent 0df2530 commit 5928144

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

types/public/ReactNativeTypes.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ export interface NativeMethods {
8686
* _Can also be called with a relativeNativeNodeHandle but is deprecated._
8787
*/
8888
measureLayout(
89-
relativeToNativeComponentRef: HostComponent<unknown> | number,
89+
relativeToNativeComponentRef:
90+
| React.ElementRef<HostComponent<unknown>>
91+
| number,
9092
onSuccess: MeasureLayoutOnSuccessCallback,
91-
onFail: () => void /* currently unused */,
93+
onFail?: () => void,
9294
): void;
9395

9496
/**

0 commit comments

Comments
 (0)