diff --git a/dist/abort-controller.d.ts b/dist/abort-controller.d.ts index eb3c8d7..75852fb 100644 --- a/dist/abort-controller.d.ts +++ b/dist/abort-controller.d.ts @@ -1,40 +1,43 @@ -import { EventTarget } from 'event-target-shim'; +import { EventTarget } from "event-target-shim" -export declare type Events = { - abort: any; -}; -export declare type EventAttributes = { - onabort: any; -}; +type Events = { + abort: any +} +type EventAttributes = { + onabort: any +} /** * The signal class. * @see https://dom.spec.whatwg.org/#abortsignal */ -export declare class AbortSignal extends EventTarget { - /** - * AbortSignal cannot be constructed directly. - */ - constructor(); - /** - * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise. - */ - readonly aborted: boolean; +declare class AbortSignal extends EventTarget { + /** + * AbortSignal cannot be constructed directly. + */ + constructor() + /** + * Returns `true` if this `AbortSignal`"s `AbortController` has signaled to abort, and `false` otherwise. + */ + readonly aborted: boolean } /** * The AbortController. * @see https://dom.spec.whatwg.org/#abortcontroller */ -export default class AbortController { - /** - * Initialize this controller. - */ - constructor(); - /** - * Returns the `AbortSignal` object associated with this object. - */ - readonly signal: AbortSignal; - /** - * Abort and signal to any observers that the associated activity is to be aborted. - */ - abort(): void; -} \ No newline at end of file +declare class AbortController { + /** + * Initialize this controller. + */ + constructor() + /** + * Returns the `AbortSignal` object associated with this object. + */ + readonly signal: AbortSignal + /** + * Abort and signal to any observers that the associated activity is to be aborted. + */ + abort(): void +} + +export default AbortController +export { AbortController, AbortSignal } diff --git a/package.json b/package.json index 1fd3c5f..9756644 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "lint": "eslint . --ext .ts", "build": "run-s -s build:*", "build:rollup": "rollup -c", - "build:dts": "dts-bundle-generator -o dist/abort-controller.d.ts src/abort-controller.ts", + "build:dts": "dts-bundle-generator -o dist/abort-controller.d.ts src/abort-controller.ts && ts-node scripts/fix-dts", "test": "run-s -s lint test:*", "test:mocha": "nyc mocha test/*.ts", "test:karma": "karma start --single-run", diff --git a/scripts/fix-dts.ts b/scripts/fix-dts.ts new file mode 100644 index 0000000..a362064 --- /dev/null +++ b/scripts/fix-dts.ts @@ -0,0 +1,18 @@ +import fs from "fs" + +fs.writeFileSync( + "dist/abort-controller.d.ts", + [ + fs + .readFileSync("dist/abort-controller.d.ts", "utf8") + .replace(/export declare type/gu, "type") + .replace(/export (?:declare|default) class/gu, "declare class") + .replace(/\t/gu, " ") + .replace(/'/gu, '"') + .replace(/;\n/gu, "\n"), + "", + "export default AbortController", + "export { AbortController, AbortSignal }", + "", + ].join("\n"), +)