From eb09248f54827b4db651b3f46961c156b929633f Mon Sep 17 00:00:00 2001 From: Daniil Samoylov Date: Wed, 4 Apr 2018 20:54:53 +1200 Subject: [PATCH] fix(typescript): Update ElementContext type (#822) * fixes 819: Correct typings for ElementContext * Update other issues in typings to get the TS scripts pass --- axe.d.ts | 14 +++++--------- typings/axe-core/axe-core-tests.ts | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/axe.d.ts b/axe.d.ts index 9c7ff12a4a..008754ad54 100644 --- a/axe.d.ts +++ b/axe.d.ts @@ -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 @@ -132,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'] }