Make AbortSignal abort and timeout correctly static, add AbortSignal.any (#55371)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55371

`AbortSignal` `abort` and `timeout` are incorrectly typed as instance methods - they should be static methods.

Also add the static `any()`, which returns a signal composed of other signals.

MDN:
 - [`AbortSignal.any(signals: Iterable<AbortSignal>)`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static)
 - [`AbortSignal.abort(reason?: any)`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort_static)
 - [`AbortSignal.timeout(time: number)`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static)

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D91904485

fbshipit-source-id: 0850c731cfaf1bf967582c85427acbd6bebcb5aa
This commit is contained in:
Rob Hogan authored and meta-codesync[bot] committed 2026-01-30 11:56:43 -08:00
1 parent aa84ed5c29
commit 31f7e84600
1 file changed
+3 -2
+3 -2
View File
@@ -609,12 +609,13 @@ declare class AbortController {
}
declare class AbortSignal extends EventTarget {
abort(reason?: $FlowFixMe): AbortSignal;
static abort(reason?: $FlowFixMe): AbortSignal;
static any(signals: Iterable<AbortSignal>): AbortSignal;
+aborted: boolean;
onabort: (event: Event) => unknown;
+reason: $FlowFixMe;
throwIfAborted(): void;
timeout(time: number): AbortSignal;
static timeout(time: number): AbortSignal;
}
declare function fetch(