Skip to content

Commit 4a8dcb3

Browse files
emily8rownmeta-codesync[bot]
authored andcommitted
Add isBinary parameter to ws$MessageListener type
Summary: X-link: react/react-native#55137 Changelog: [Internal] - Add missing isBinary parameter to ws$MessageListener Flow type The `ws` library's `message` event passes `(data, isBinary)` to callbacks, but the flow-typed definition only included `data`. This caused Flow errors when correctly using `isBinary` to detect binary messages. This fix adds the missing `isBinary: boolean` parameter to `ws$MessageListener` in both flow-typed locations to keep them synchronized: - `xplat/js/tools/metro/flow-typed/npm/ws_v7.x.x.js` - `xplat/js/react-native-github/flow-typed/npm/ws_v7.x.x.js` This is backwards compatible - existing code that doesn't use `isBinary` will continue to work since for flow a function with fewer parameters is a subtype for callbacks. websocket was always sending both parameters and the javascript just ignored the second one. https://github.com/websockets/ws/blob/master/doc/ws.md#event-message Reviewed By: huntie Differential Revision: D90507002 fbshipit-source-id: 6ab78809213ec167416de35a12cd1fe5c328046f
1 parent f9c64be commit 4a8dcb3

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

flow-typed/npm/ws_v7.x.x.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ declare type ws$CloseListener = (code: number, reason: string) => unknown;
134134
declare type ws$ErrorListener = (error: Error) => unknown;
135135
declare type ws$MessageListener = (
136136
data: string | Buffer | ArrayBuffer | Array<Buffer>,
137+
isBinary: boolean,
137138
) => unknown;
138139
declare type ws$OpenListener = () => unknown;
139140
declare type ws$PingListener = (Buffer) => unknown;

0 commit comments

Comments
 (0)