TypeScript's built-in typings are currently missing AbortSignal.timeout. How does one write a .d.ts file to add it?
This doesn't work:
declare namespace AbortSignal {
function timeout(milliseconds: number): AbortSignal;
}
Duplicate identifier 'AbortSignal'.(2300)
lib.dom.d.ts(1984, 11): 'AbortSignal' was also declared here.
lib.dom.d.ts(1996, 13): and here.
If you are using TypeScript 4.5+, you can solve this by installing @types/web as a lib replacement:
pnpm add @typescript/lib-dom@npm:@types/web --save-dev
npm install @typescript/lib-dom@npm:@types/web --save-dev
yarn add @typescript/lib-dom@npm:@types/web --dev
This requires you to have "dom" in the lib-section of your tsconfig.json.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With