Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Sinon SinonStubbedInstance with Typescript

I'm using sinon to stub an instance of express-Request.
It looks something like this:

let req = sinon.createStubInstance(Request);

My method accepts req: Request but my IDE complains about me using SinonStubbedInstance<Request> rather than Request.
I've tried using req as Request but I still get a warning about 'may be a mistake' and that I should first cast to unknown and only then to Request.

I actually don't need anything from this parameter so I really just want to stub it quickly and easily.

like image 742
SagiLow Avatar asked Jul 17 '26 19:07

SagiLow


1 Answers

When using it in the call to your method, just cast it:

myMethod(req as any);
like image 110
Max Yankov Avatar answered Jul 20 '26 20:07

Max Yankov