dequelabs/axe-core-npm

reporter-earl: reporter type is not compatible with axe-core

straker opened this issue · 1 comments

In TypeScript, trying to assign the reporter to axe.configure fails as the RawResult type that the reporter uses is not the same as the RawResult that axe-core uses.

I was surprised this wasn't caught in a test but then I discovered that the one test where we try to use the reporter assigns it as any so it's never type checked.

import reporter from '@axe-core/reporter-earl';
axe.configure({ reporter });

/*
error TS2322: Type '(rawResults: RawResult[], {}: {}, callback: Function) => void' is not assignable to type 'string | AxeReporter<unknown>'.
  Type '(rawResults: RawResult[], {}: {}, callback: Function) => void' is not assignable to type 'AxeReporter<unknown>'.
    Types of parameters 'rawResults' and 'rawResults' are incompatible.
      Type 'import("/node_modules/axe-core/axe").RawResult[]' is not assignable to type 'RawResult[]'.
        Type 'import("/node_modules/axe-core/axe").RawResult' is not assignable to type 'RawResult'.
          Types of property 'violations' are incompatible.
            Type 'RawNodeResult<"failed">[]' is not assignable to type 'RawNodeResult[]'.
              Property 'node' is missing in type 'RawNodeResult<"failed">' but required in type 'RawNodeResult'.

2 axe.configure({ reporter });
*/

we have a ticket related to this