Skip to content
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

chore(type-checking): Cannot use only callback in run() without ts error #707

Merged
merged 2 commits into from
Feb 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions axe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ declare module axe {

type RunOnlyType = "rule" | "rules" | "tag" | "tags";

type RunCallback = (error: Error, results:AxeResults) => void;

interface ElementContext {
node?: Object,
selector?: string,
Expand All @@ -26,6 +28,13 @@ declare module axe {
}
values?: TagValue[]
}
interface RunOptions {
runOnly?: RunOnly,
rules?: Object,
iframes?: Boolean,
elementRef?: Boolean,
selectors?: Boolean
}
interface AxeResults {
url: string,
timestamp: string,
Expand Down Expand Up @@ -117,12 +126,18 @@ declare module axe {
/**
* Runs a number of rules against the provided HTML page and returns the resulting issue list
*
* @param {Object} context Optional The `Context` specification object @see Context
* @param {Array} options Optional Options passed into rules or checks, temporarily modifying them.
* @param {Function} callback Optional The function to invoke when analysis is complete.
* @returns {any} results If the callback was not defined, aXe will return a Promise instead.
* @param {ElementContext} context Optional The `Context` specification object @see Context
* @param {RunOptions} options Optional Options passed into rules or checks, temporarily modifying them.
* @param {RunCallback} callback Optional The function to invoke when analysis is complete.
* @returns {Promise<AxeResults>|void} If the callback was not defined, aXe will return a Promise.
*/
function run(context?: ElementContext, options?: {runOnly?: RunOnly, rules?: Object, iframes?: Boolean, elementRef?: Boolean, selectors?: Boolean}, callback?: (error: Error, results:AxeResults) => void): any
function run(context: ElementContext): Promise<AxeResults>
function run(options: RunOptions): Promise<AxeResults>
function run(callback: (error: Error, results:AxeResults) => void): void
function run(context: ElementContext, callback: RunCallback): void
function run(options: RunOptions, callback: RunCallback): void
function run(context: ElementContext, options: RunOptions): Promise<AxeResults>
function run(context: ElementContext, options: RunOptions, callback: RunCallback): void

/**
* Starts analysis on the current document and its subframes
Expand Down