Skip to content

Commit

Permalink
fix(axe.d.ts): add typings for preload options object (#4543)
Browse files Browse the repository at this point in the history
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 <awa@xima.de>
  • Loading branch information
blutorange and awa-xima authored Jul 30, 2024
1 parent cf8f38e commit cfd2974
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion axe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
7 changes: 7 additions & 0 deletions typings/axe-core/axe-core-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cfd2974

Please sign in to comment.