Skip to content

Commit

Permalink
fix(type-checking): Improve typescript axe.run call signature (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
plumpNation authored and WilcoFiers committed Feb 5, 2018
1 parent 0fe74d8 commit de45ee3
Showing 1 changed file with 20 additions and 5 deletions.
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

0 comments on commit de45ee3

Please sign in to comment.