-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript module definitions #44
Comments
I don't think anyone has created TS definitions yet, a PR would be great |
What approach are you planning; rewrite in TS and generate .d.ts files on build, or manually writing the .d.ts files? |
FWIW, I pushed the commit "e9880c8" to master now, it upgrades all dependencies to the latest versions and re-pins chromedriver/geckodriver to fresh versions. To run the tests you must have chrome v80 installed and then just do "npm test". The firefox tests are a bit more flexible in terms on version, you can run them using "npm run test-firefox". |
I do believe the following typings can be used: declare module 'abortcontroller-polyfill/dist/cjs-ponyfill' {
/** A controller object that allows you to abort one or more DOM requests as and when desired. */
interface AbortController {
/**
* Returns the AbortSignal object associated with this object.
*/
readonly signal: AbortSignal
/**
* 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.
*/
abort(): void
}
const AbortController: {
prototype: AbortController
new(): AbortController
}
interface AbortSignalEventMap {
'abort': Event
}
/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
interface AbortSignal extends EventTarget {
/**
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
*/
readonly aborted: boolean
onabort: ((this: AbortSignal, ev: Event) => any) | null
addEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void
removeEventListener<K extends keyof AbortSignalEventMap>(type: K, listener: (this: AbortSignal, ev: AbortSignalEventMap[K]) => any, options?: boolean | EventListenerOptions): void
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void
}
const AbortSignal: {
prototype: AbortSignal
new(): AbortSignal
}
} |
@mo Could you add the above code to .d.ts file please? |
TypeScript has fixed this issue in latest version: microsoft/TypeScript#51567 |
I'm trying to use this in a Typescript project, but am having to in an odd way because this library doesn't have type module definitions. Any plans to add this? I'm happy to spin up a PR if it's helpful.
The text was updated successfully, but these errors were encountered: