Search code examples
typescriptvuejs3vitestvue-tsc

VueWrapper error after typescript update to v5.5.2


When I update my project's TypeScript dependency to the version v5.5.2 from 5.4.5 it completely breaks my checks in test.ts files specifically with VueWrapper type, I use vitest. type error

My usual implementation looks like:

let wrapper: VueWrapper<InstanceType<typeof SomeComponentToTest>>;

//also try
let wrapper: VueWrapper<any>;

//and 
let wrapper: VueWrapper<typeof SomeComponentToTest>;


describe('SomeComponentToTest component tests', () => {
    beforeEach(() => {
     //before each test set up
    }
    test('some test to the component' ()=>{
     //...
    })
}

But always get the same error in the wrapper declaration: Generic type 'VueWrapper<VM, T>' requires 2 type argument(s)

The error seems self-explanatory, but I have no idea how to fix it.

the tests keeps working as usual, the problem is only when i run vue-tsc --noEmit


Solution

  • this problem is related to one error on the src/vue-test-utils.d.ts file:

        declare module '@vue/test-utils' {
          export class VueWrapper {
            findByTestId(testId: string): DOMWrapper[];
      }
    

    when it should be:

    declare module '@vue/test-utils' {
      interface VueWrapper {
        findByTestId(testId: string): DOMWrapper[];
      }
    

    that solve the issue pd: sorry for the bad english