From cfd297498c0e34edd5ff7e62935060bb9dda4db7 Mon Sep 17 00:00:00 2001 From: Andre Wachsmuth Date: Tue, 30 Jul 2024 16:48:34 +0200 Subject: [PATCH] fix(axe.d.ts): add typings for preload options object (#4543) Adds the TypeScript typings for passing an object to the `preload` setting for `axe.run`, as documented here: https://www.deque.com/axe/core-documentation/api-documentation/#preload-configuration-details > Specifying an object ```js axe.run( { preload: { assets: ['cssom'], timeout: 50000 } }, (err, results) => { // ... } ); ``` Co-authored-by: Andre Wachsmuth --- axe.d.ts | 6 +++++- typings/axe-core/axe-core-tests.ts | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/axe.d.ts b/axe.d.ts index 5c4197a872..47bca29ff0 100644 --- a/axe.d.ts +++ b/axe.d.ts @@ -143,10 +143,14 @@ declare namespace axe { iframes?: boolean; elementRef?: boolean; frameWaitTime?: number; - preload?: boolean; + preload?: boolean | PreloadOptions; performanceTimer?: boolean; pingWaitTime?: number; } + interface PreloadOptions { + assets: string[]; + timeout?: number; + } interface AxeResults extends EnvironmentData { toolOptions: RunOptions; passes: Result[]; diff --git a/typings/axe-core/axe-core-tests.ts b/typings/axe-core/axe-core-tests.ts index 1b8a9fda60..43a1286ff0 100644 --- a/typings/axe-core/axe-core-tests.ts +++ b/typings/axe-core/axe-core-tests.ts @@ -35,6 +35,13 @@ axe.run( console.log(error || results); } ); +// axe.run preload: boolean +axe.run({ preload: false }); +axe.run({ preload: true }); +// axe.run preload: options +axe.run({ preload: { assets: ['cssom'] } }); +axe.run({ preload: { assets: ['cssom'], timeout: 50000 } }); + export async function runAsync() { await axe.run('main'); // Single selector await axe.run(['main']); // Array of one selector