Skip to content

Commit

Permalink
fix(typescript): Update ElementContext type (#822)
Browse files Browse the repository at this point in the history
* fixes 819: Correct typings for ElementContext
* Update other issues in typings to get the TS scripts pass
  • Loading branch information
Obi-Dann authored and WilcoFiers committed Apr 4, 2018
1 parent 8f4d886 commit eb09248
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 5 additions & 9 deletions axe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ declare module axe {
type RunOnlyType = "rule" | "rules" | "tag" | "tags";

type RunOnlyObject = {
include?: string[],
exclude?: string[]
include?: string[] | string[][],
exclude?: string[] | string[][]
}

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

interface ElementContext {
node?: Object,
selector?: string,
include?: any[],
exclude?: any[]
}
type ElementContext = Node | string | RunOnlyObject;

interface RunOnly {
type: RunOnlyType,
values?: TagValue[] | RunOnlyObject
Expand Down Expand Up @@ -132,7 +128,7 @@ declare module axe {
* @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): Promise<AxeResults>
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
Expand Down
4 changes: 2 additions & 2 deletions typings/axe-core/axe-core-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ axe.run({exclude: [$fixture[0]]}, {}, (error: Error, results: axe.AxeResults) =>
console.log(error || results)
})
// additional configuration options
axe.run(context, {iframes: false, selectors: false, elementRef: false},
axe.run(context, {iframes: false, selectors: false, elementRef: false},
(error: Error, results: axe.AxeResults) => {
console.log(error || results.passes.length);
});
Expand All @@ -45,7 +45,7 @@ axe.run(context, tagConfig, (error: Error, results: axe.AxeResults) => {
})
var includeExcludeTagsRunOnly: axe.RunOnly = {
type: 'tags',
value: {
values: {
include: ['wcag2a', 'wcag2aa'],
exclude: ['experimental']
}
Expand Down

0 comments on commit eb09248

Please sign in to comment.