Skip to content

Commit de45ee3

Browse files
plumpNationWilcoFiers
authored andcommitted
fix(type-checking): Improve typescript axe.run call signature (#707)
1 parent 0fe74d8 commit de45ee3

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

axe.d.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ declare module axe {
1212

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

15+
type RunCallback = (error: Error, results:AxeResults) => void;
16+
1517
interface ElementContext {
1618
node?: Object,
1719
selector?: string,
@@ -26,6 +28,13 @@ declare module axe {
2628
}
2729
values?: TagValue[]
2830
}
31+
interface RunOptions {
32+
runOnly?: RunOnly,
33+
rules?: Object,
34+
iframes?: Boolean,
35+
elementRef?: Boolean,
36+
selectors?: Boolean
37+
}
2938
interface AxeResults {
3039
url: string,
3140
timestamp: string,
@@ -117,12 +126,18 @@ declare module axe {
117126
/**
118127
* Runs a number of rules against the provided HTML page and returns the resulting issue list
119128
*
120-
* @param {Object} context Optional The `Context` specification object @see Context
121-
* @param {Array} options Optional Options passed into rules or checks, temporarily modifying them.
122-
* @param {Function} callback Optional The function to invoke when analysis is complete.
123-
* @returns {any} results If the callback was not defined, aXe will return a Promise instead.
129+
* @param {ElementContext} context Optional The `Context` specification object @see Context
130+
* @param {RunOptions} options Optional Options passed into rules or checks, temporarily modifying them.
131+
* @param {RunCallback} callback Optional The function to invoke when analysis is complete.
132+
* @returns {Promise<AxeResults>|void} If the callback was not defined, aXe will return a Promise.
124133
*/
125-
function run(context?: ElementContext, options?: {runOnly?: RunOnly, rules?: Object, iframes?: Boolean, elementRef?: Boolean, selectors?: Boolean}, callback?: (error: Error, results:AxeResults) => void): any
134+
function run(context: ElementContext): Promise<AxeResults>
135+
function run(options: RunOptions): Promise<AxeResults>
136+
function run(callback: (error: Error, results:AxeResults) => void): void
137+
function run(context: ElementContext, callback: RunCallback): void
138+
function run(options: RunOptions, callback: RunCallback): void
139+
function run(context: ElementContext, options: RunOptions): Promise<AxeResults>
140+
function run(context: ElementContext, options: RunOptions, callback: RunCallback): void
126141

127142
/**
128143
* Starts analysis on the current document and its subframes

0 commit comments

Comments
 (0)