Closed dotennin closed 1 year ago
import * as bar from './bar';
(<any>bar).fooXXX();
I don't think a babel plugin can really do much to address this. I would suggest either following @sergei-startsev's example or adding a dummy function declaration to the source module to satisfy type checking, e.g.:
export declare function rewire$XXX(_: any): void;
export declare function restore(): void;
I don't think a babel plugin can really do much to address this. I would suggest either following @sergei-startsev's example or adding a dummy function declaration to the source module to satisfy type checking, e.g.:
export declare function rewire$XXX(_: any): void; export declare function restore(): void;
Yeah , In addition to trouble, but this is the safest. we need to add a corresponding declaration for each variable that needs to be mocked,
import * as bar from './bar'; (<any>bar).fooXXX();
It's also a good idea,
Actually I did the following way to resolve this issue.
const foo = require('path to file')
foo.rewire$XXX(() => mockXXX);
This is my current simpler way of avoiding any
and ts-ignore
etc.(but loses type checking 😢 )
Thanks for your advice.
Got this error when importing
rewireXXX
in the test file . Any good idea for Typescript support ?*excepts ts-ignore.