Skip to content

Commit

Permalink
add type guard to isFbtInstance
Browse files Browse the repository at this point in the history
Reviewed By: SamChou19815

Differential Revision: D54232880

fbshipit-source-id: fa68171c0deb9e6fbffa81f218e37f8370094d19
  • Loading branch information
panagosg7 authored and facebook-github-bot committed Feb 27, 2024
1 parent 7b00393 commit 2970a2d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 1 addition & 1 deletion flow-types/libdef/fbt.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ type $GenericFbtFunctionAPI<Input, Output, ParamInput, ParamOutput> = {
enableJsonExportMode: () => void,
// Only used in React Native in fbsource
disableJsonExportMode: () => void,
isFbtInstance: (value: mixed) => boolean,
isFbtInstance: (value: mixed) => value is $FbtResultBase,
...
};

Expand Down
5 changes: 1 addition & 4 deletions runtime/shared/fbt.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,10 +471,7 @@ function disableJsonExportMode(): void {
jsonExportMode = false;
}

// Must define this as a standalone function
// because Flow doesn't support %check on as a class static method
// $FlowFixMe[deprecated-type]
function isFbtInstance(value: mixed): boolean %checks {
function isFbtInstance(value: mixed): value is FbtResultBase {
return value instanceof FbtResultBase;
}

Expand Down

0 comments on commit 2970a2d

Please sign in to comment.