type MutableRefObject<T> = {
    current: T | null;  // generic type 
};



  const abortController: MutableRefObject<AbortController> = useRef(null);
    
  const doRequest = () => {
          abortController.current = new AbortController();
          window
              .fetch(url, {
                  method: 'GET',
                  signal: abortController.current.signal,
              })
              .then(res => res.json());
      };

      

const cancelRequest = () => {
        abortController.current?.abort();  // ? for Optional chaining
};

Basically the type of AbortController is AbortController . I created the type MutableRefObject for useRef hook . The RefObject provided by React throws another error because the current property is readonly on RefObject .

Answer from Josef Shady on Stack Overflow
🌐
DEV Community
dev.to › bil › using-abortcontroller-with-react-hooks-and-typescript-to-cancel-window-fetch-requests-1md4
Using AbortController (with React Hooks and TypeScript) to cancel window.fetch requests - DEV Community
March 27, 2019 - const abortController = new AbortController() const promise = window .fetch('https://api.example.com/v1/me', { headers: {Authorization: `Bearer [my access token]`}, method: 'GET', mode: 'cors', signal: abortController.signal, }) .then(res => res.json()) .then(res => { console.log(res.me) }) .catch(err => { console.error('Request failed', err) }) // Cancel the request if it takes more than 5 seconds setTimeout(() => abortController.abort(), 5000)
Discussions

TypeScript interface for abort signal not compatible with AbortController
I have installed node-fetch 2.6.0, using inside Electron 8 with Chromium 80.0 I think: const controller = new AbortController() const signal:AbortSignal = controller.signal; const timeout = setTime... More on github.com
🌐 github.com
7
February 28, 2020
AbortController.abort is missing parameter support
lib Update Request Configuration Check My compilation target is es5 and my lib is ["dom", "dom.iterable", "esnext"]. (But i think that does not matter here) Missing / ... More on github.com
🌐 github.com
6
January 19, 2022
🌐
Medium
zzdjk6.medium.com › a-simple-implementation-of-abortable-promise-using-abortcontroller-with-typescript-2c163ee050e8
A Simple Implementation of Abortable Promise Using AbortController with TypeScript | by Thor Chen | Medium
March 22, 2020 - Every AbortController can only be used once and we have to create new ones after abort happens. That is, the only effective call to .abort() is the first time. After we called .abort() on an AbortController, the AbortSignal is used and remain aborted.
🌐
GitHub
github.com › node-fetch › node-fetch › issues › 741
TypeScript interface for abort signal not compatible with AbortController · Issue #741 · node-fetch/node-fetch
February 28, 2020 - const controller = new AbortController() const signal:AbortSignal = controller.signal; const timeout = setTimeout(() => { controller.abort(); }, 15000); const res = await fetch(`https://api.keygen.sh/v1/accounts/${KEYGEN_ACCOUNT_ID}/licenses/actions/validate-key`, { method: 'POST', signal: signal, headers: { 'Content-Type': 'application/vnd.api+json', 'Accept': 'application/vnd.api+json' }, body: JSON.stringify({ meta: { scope: { product: KEYGEN_PRODUCT_ID }, key: license_key } }), })
Author   Sakari369
Find elsewhere
🌐
Medium
medium.com › @michelo851a1203 › javascript-typescript-fetch-abortcontroller-and-cancellation-how-to-cancel-received-message-with-738d7fe2b0e6
Javascript/Typescript fetch AbortController and Cancellation: How to cancel received message with Go Gin | by Ho Michael | Medium
May 14, 2023 - <script setup lang="ts"> import { ref } from 'vue'; const abortReference = ref(new AbortController()); const getRequest = async () => { abortReference.value = new AbortController(); try { const response = await fetch('http://localhost:8080', { method: 'GET', signal: abortReference.value.signal, }) const mainContent = await response.text(); console.log(mainContent); } catch{ console.error('api error'); } } const quitRequest = () => { console.log('cancel request'); abortReference.value.abort(); } </script> <template> <button @click="getRequest"> click to request </button> <button @click="quitRequest"> Abort Request </button> </template>
🌐
Microsoft Developer Blogs
devblogs.microsoft.com › dev blogs › azure sdk blog › how to use abort signals to cancel operations in the azure sdk for javascript/typescript
How to use abort signals to cancel operations in the Azure SDK for JavaScript/TypeScript - Azure SDK Blog
June 12, 2020 - The new Azure SDK libraries for JavaScript and TypeScript have adopted abort signals situations like these. AbortController and AbortSignal are standard features in the browser and are used with the fetch API to abort in-progress network requests.
🌐
Medium
leapcell.medium.com › abortcontroller-what-you-dont-know-f4655264e9bc
AbortController: What You Don’t Know | by Leapcell | Medium
January 16, 2025 - AbortController: Used to explicitly cancel associated signals via controller.abort().
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › AbortController
AbortController - Web APIs - MDN Web Docs
September 17, 2025 - The AbortController interface represents a controller object that allows you to abort one or more Web requests as and when desired.
🌐
GitHub
github.com › mysticatea › abort-controller
GitHub - mysticatea/abort-controller: An implementation of WHATWG AbortController interface. · GitHub
import AbortController from "abort-controller" const controller = new AbortController() const signal = controller.signal signal.addEventListener("abort", () => { console.log("aborted!") }) controller.abort()
Starred by 309 users
Forked by 37 users
Languages   TypeScript 65.2% | JavaScript 34.8%
🌐
GitHub
gist.github.com › cakrads › 9123120f8a265f1d39451f3f1105d94b
Simple example how to implement abort controller in typescript react.js. · GitHub
Simple example how to implement abort controller in typescript react.js. - react-fetch-abort-controller.ts
🌐
GitHub
github.com › microsoft › TypeScript › issues › 47505
AbortController.abort is missing parameter support · Issue #47505 · microsoft/TypeScript
January 19, 2022 - lib Update Request Configuration Check My compilation target is es5 and my lib is ["dom", "dom.iterable", "esnext"]. (But i think that does not matter here) Missing / Incorrect Definition Abort Controller.abort() in lib.dom.d.ts does not...
Author   laurenzhonauer
🌐
Webdevtutor
webdevtutor.net › blog › typescript-abortcontroller
Mastering AbortController in TypeScript: A Comprehensive Guide
In this guide, we've covered the basics of using AbortController in TypeScript to handle asynchronous operations and cancellations effectively.
🌐
xjavascript
xjavascript.com › blog › abortcontroller-typescript
Mastering `AbortController` in TypeScript — xjavascript.com
Introduced as part of the Web API, `AbortController` provides a standardized way to cancel asynchronous operations. In this blog post, we'll explore how to use `AbortController` in TypeScript, covering fundamental concepts, usage methods, common ...
🌐
DEV Community
dev.to › rashidshamloo › adding-timeout-and-multiple-abort-signals-to-fetch-typescriptreact-33bb
Adding timeout and multiple abort signals to fetch() (TypeScript/React) - DEV Community
April 30, 2023 - "At time of writing there is no way to combine multiple signals. This means that you can't directly abort a download using either a timeout signal or by calling AbortController.abort().
🌐
Carl Rippon
carlrippon.com › cancelling-fetch-in-react-and-typescript
Cancelling fetch in React and TypeScript
February 24, 2021 - The signal property in AbortController can be passed into fetch. AbortController.abort can be then called to cancel the request. Cancelling fetch raises an error that can be swallowed using try catch. The complete code is in this gist. ... A comprehensive guide to building modern React applications with TypeScript.
🌐
LogRocket
blog.logrocket.com › home › the complete guide to the abortcontroller api
The complete guide to the AbortController API - LogRocket Blog
March 12, 2025 - An instance of the AbortController class exposes the abort method and the signal property. Invoking the abort method emits the abort event to notify the abortable API watching the controller about the cancellation.