I think that I have to mock an API method with the full signature for it to get picked, because until I did that, it wouldn’t get called.
vi.mock("my-module", async (importOriginal) => {
const originalModule = await importOriginal();
return {
...(originalModule as object),
useGetSomeData: ({param1, param2}: {param1: Param1Type[],
param2: Param2Type}) => {
//const _noop = [param1, param2];
return {
data: getMockLocators(),
};
},
...
But the mock does not need these parameters, because it only returns some static data.
The problem: if I don’t reference the parameters, I get the compiler error
All destructured elements are unused.ts(6198),
and if I assign them to a local variable called ‘_noop’ just so that they are used, I get
'_noop' is declared but its value is never read.ts(6133)
This question has come up before in various flavors, but I do not want to turn the rule off via noUnusedLocals
compiler option. What else can I do to either reference those parameters by a piece of inert code that has no side effects, or to suppress the errors altogether?