mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix: add typings for AbortSignal.reason (#12730)
This commit is contained in:
parent
e00bfecf96
commit
08067b5e12
2 changed files with 9 additions and 1 deletions
|
@ -54,3 +54,9 @@ unitTest(function controllerHasProperToString() {
|
||||||
const actual = Object.prototype.toString.call(new AbortController());
|
const actual = Object.prototype.toString.call(new AbortController());
|
||||||
assertEquals(actual, "[object AbortController]");
|
assertEquals(actual, "[object AbortController]");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
unitTest(function abortReason() {
|
||||||
|
const signal = AbortSignal.abort("hey!");
|
||||||
|
assertEquals(signal.aborted, true);
|
||||||
|
assertEquals(signal.reason, "hey!");
|
||||||
|
});
|
||||||
|
|
4
ext/web/lib.deno_web.d.ts
vendored
4
ext/web/lib.deno_web.d.ts
vendored
|
@ -258,7 +258,7 @@ declare class AbortController {
|
||||||
readonly signal: AbortSignal;
|
readonly signal: AbortSignal;
|
||||||
/** Invoking this method will set this object's AbortSignal's aborted flag and
|
/** Invoking this method will set this object's AbortSignal's aborted flag and
|
||||||
* signal to any observers that the associated activity is to be aborted. */
|
* signal to any observers that the associated activity is to be aborted. */
|
||||||
abort(): void;
|
abort(reason?: any): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AbortSignalEventMap {
|
interface AbortSignalEventMap {
|
||||||
|
@ -271,6 +271,7 @@ interface AbortSignal extends EventTarget {
|
||||||
/** Returns true if this AbortSignal's AbortController has signaled to abort,
|
/** Returns true if this AbortSignal's AbortController has signaled to abort,
|
||||||
* and false otherwise. */
|
* and false otherwise. */
|
||||||
readonly aborted: boolean;
|
readonly aborted: boolean;
|
||||||
|
readonly reason?: unknown;
|
||||||
onabort: ((this: AbortSignal, ev: Event) => any) | null;
|
onabort: ((this: AbortSignal, ev: Event) => any) | null;
|
||||||
addEventListener<K extends keyof AbortSignalEventMap>(
|
addEventListener<K extends keyof AbortSignalEventMap>(
|
||||||
type: K,
|
type: K,
|
||||||
|
@ -297,6 +298,7 @@ interface AbortSignal extends EventTarget {
|
||||||
declare var AbortSignal: {
|
declare var AbortSignal: {
|
||||||
prototype: AbortSignal;
|
prototype: AbortSignal;
|
||||||
new (): AbortSignal;
|
new (): AbortSignal;
|
||||||
|
abort(reason?: any): AbortSignal;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface FileReaderEventMap {
|
interface FileReaderEventMap {
|
||||||
|
|
Loading…
Add table
Reference in a new issue