From f662a130cba9d4744ea786ee954fa49f06dab9e3 Mon Sep 17 00:00:00 2001 From: Daniil Samoylov Date: Wed, 4 Apr 2018 10:34:27 +1200 Subject: [PATCH 1/2] fixes 819: Correct typings for ElementContext --- axe.d.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/axe.d.ts b/axe.d.ts index 9c7ff12a4a..a4a734a1e9 100644 --- a/axe.d.ts +++ b/axe.d.ts @@ -19,12 +19,8 @@ declare module axe { 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 From 2a15df46f8178c4486015d8e016feaa1e57566fd Mon Sep 17 00:00:00 2001 From: Daniil Samoylov Date: Wed, 4 Apr 2018 10:34:55 +1200 Subject: [PATCH 2/2] Update other issues in typings to get the TS scripts pass --- axe.d.ts | 6 +++--- typings/axe-core/axe-core-tests.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/axe.d.ts b/axe.d.ts index a4a734a1e9..008754ad54 100644 --- a/axe.d.ts +++ b/axe.d.ts @@ -13,8 +13,8 @@ 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; @@ -128,7 +128,7 @@ declare module axe { * @param {RunCallback} callback Optional The function to invoke when analysis is complete. * @returns {Promise|void} If the callback was not defined, aXe will return a Promise. */ - function run(context: ElementContext): Promise + function run(context?: ElementContext): Promise function run(options: RunOptions): Promise function run(callback: (error: Error, results:AxeResults) => void): void function run(context: ElementContext, callback: RunCallback): void diff --git a/typings/axe-core/axe-core-tests.ts b/typings/axe-core/axe-core-tests.ts index a636177e89..a7ef92577d 100644 --- a/typings/axe-core/axe-core-tests.ts +++ b/typings/axe-core/axe-core-tests.ts @@ -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); }); @@ -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'] }