dequelabs / axe-core-npm

Mozilla Public License 2.0
592 stars 67 forks source link

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

Closed straker closed 9 months ago

straker commented 9 months ago

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 });
*/
padmavemulapati commented 9 months ago

we have a ticket related to this