diff --git a/types/sinon/ts3.1/index.d.ts b/types/sinon/ts3.1/index.d.ts index 6641d3510f..6604784b20 100644 --- a/types/sinon/ts3.1/index.d.ts +++ b/types/sinon/ts3.1/index.d.ts @@ -404,7 +404,7 @@ declare namespace Sinon { * The Promise library can be overwritten using the usingPromise method. * Since sinon@2.0.0 */ - resolves(value?: TReturnValue extends PromiseLike ? TResolveValue : never): SinonStub; + resolves(value?: TReturnValue extends PromiseLike ? TResolveValue : any): SinonStub; /** * Causes the stub to return a Promise which resolves to the argument at the provided index. * stub.resolvesArg(0); causes the stub to return a Promise which resolves to the first argument. diff --git a/types/sinon/ts3.1/sinon-tests.ts b/types/sinon/ts3.1/sinon-tests.ts index c7bd7a6c9c..8a12a01aef 100644 --- a/types/sinon/ts3.1/sinon-tests.ts +++ b/types/sinon/ts3.1/sinon-tests.ts @@ -491,6 +491,7 @@ function testStub() { foo(arg: string): number { return 1; } promiseFunc() { return Promise.resolve('foo'); } promiseLikeFunc() { return Promise.resolve('foo') as PromiseLike; } + unresolvableReturnFunc(): any { return Promise.resolve(); } fooDeep(arg: { s: string }): void { return undefined; } }; const instance = new obj(); @@ -501,6 +502,11 @@ function testStub() { const promiseStub = sinon.stub(instance, 'promiseFunc'); promiseStub.resolves('test'); + promiseStub.resolves(123); // $ExpectError + + const promiseUnresolvableReturn = + sinon.stub(instance, 'unresolvableReturnFunc'); + promiseUnresolvableReturn.resolves(['anything', 123, true]); const promiseLikeStub = sinon.stub(instance, 'promiseLikeFunc'); promiseLikeStub.resolves('test');