Jest tests cannot find the matchers added by CDKTF

I’m writing some Jest tests to test my CDKTF code and I’m finding an issue where when I try to call one of the matchers I get the following error message:

    error TS2339: Property 'toHaveDataSource' does not exist on type 'JestMatchers<string>'.

    33       expect(synthesized).toHaveDataSource(DataAzurermAppConfiguration);

This is what my test looks like:

    it("should reference an App Configuration data source", () => {
      const synthesized = Testing.synthScope((scope) => {
        new AppConfig(scope, "AppConfig", environmentConfig);
      });

      expect(synthesized).toHaveDataSource(DataAzurermAppConfiguration);
    });

I’ve confirmed that cdktf.Testing.setupJest() is being called and I can see the matchers on expect and expect(synthesized) when I output them to console.log.

Any ideas about what is wrong and how to fix it?

I found that if I typecase expect(syntheized) to any like this:

    it("should reference an App Configuration data source", () => {
      const synthesized = Testing.synthScope((scope) => {
        new AppConfig(scope, "AppConfig", environmentConfig);
      });

      (expect(synthesized) as any).toHaveDataSource(DataAzurermAppConfiguration);
    });

then the test works and it finds the matchers.

This is not ideal though as it gives an ESLint error now because of the explicit any.