From 823b1f467b42b6d8b68a2f4af292c2663f192cd2 Mon Sep 17 00:00:00 2001 From: Louie Colgan Date: Wed, 26 Jul 2023 03:21:52 -0700 Subject: [PATCH] fix: add signal to `Request` type (#38536) Summary: The `Request` interface provided by `types/react-native` doesn't have a `signal` property when it should as this is something that is accessible on the `Request` object. ![image](https://github.com/facebook/react-native/assets/10697889/f2d75973-61ff-4874-ad8e-2c0898b82d27) For example, running the following: #### Without providing a `signal` ```ts console.log(new Request('https://www.facebook.com')); ``` will result in the following: ```ts {"_bodyInit": undefined, "_bodyText": "", "bodyUsed": false, "credentials": "same-origin", "headers": {"map": {}}, "method": "GET", "mode": null, "referrer": null, "signal": {}, "url": "https://www.facebook.com"} ``` ## Changelog: [GENERAL] [FIXED] - Fixed missing property `signal` for the `Request` interface ## Reproduce 1. Add `new Request('https://www.facebook.com').signal` to a typescript file 2. TS will error `Property 'signal' does not exist on type 'Request'` Pull Request resolved: https://github.com/facebook/react-native/pull/38536 Test Plan: Adding to `global.d.ts` in a file will resolve the problem, demonstrating that this works. ```ts interface Request { readonly signal: AbortSignal | undefined } ``` Reviewed By: NickGerleman Differential Revision: D47660506 Pulled By: jacdebug fbshipit-source-id: ef1459fbaca5d8f31bf8539bd61ac5e447111fec --- packages/react-native/types/modules/globals.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-native/types/modules/globals.d.ts b/packages/react-native/types/modules/globals.d.ts index 02bc10af8d2139..af112c7698aec5 100644 --- a/packages/react-native/types/modules/globals.d.ts +++ b/packages/react-native/types/modules/globals.d.ts @@ -187,6 +187,7 @@ declare interface Request extends Object, Body { readonly mode: RequestMode_; readonly referrer: string; readonly url: string; + readonly signal: AbortSignal | undefined; clone(): Request; }