diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index bc265d6718..d14876b5e5 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -8,6 +8,7 @@ // Josh Goldberg // Greg Jednaszewski // John Wood +// Alec Flett // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 diff --git a/types/sinon/ts3.1/index.d.ts b/types/sinon/ts3.1/index.d.ts index bc91a3285a..d37a2b03f4 100644 --- a/types/sinon/ts3.1/index.d.ts +++ b/types/sinon/ts3.1/index.d.ts @@ -1526,7 +1526,9 @@ declare namespace Sinon { /** * Replaces a type with a Sinon stub if it's a function. */ - type SinonStubbedMember = T extends Function ? SinonStub : T; + type SinonStubbedMember = T extends ( + ...args: infer TArgs + ) => infer TReturnValue ? SinonStub : T; interface SinonFake { /** diff --git a/types/sinon/ts3.1/sinon-tests.ts b/types/sinon/ts3.1/sinon-tests.ts index b892f22980..f07c9c4600 100644 --- a/types/sinon/ts3.1/sinon-tests.ts +++ b/types/sinon/ts3.1/sinon-tests.ts @@ -67,7 +67,7 @@ function testSandbox() { sb.replaceSetter(replaceMe, 'setter', (v) => { }); const cls = class { - foo() { } + foo(arg1: string, arg2: number) { return 1; } bar: number; }; const PrivateFoo = class { @@ -81,8 +81,8 @@ function testSandbox() { const stubInstance = sb.createStubInstance(cls); const privateFooStubbedInstance = sb.createStubInstance(PrivateFoo); - stubInstance.foo.calledWith('foo'); - privateFooStubbedInstance.foo.calledWith('foo'); + stubInstance.foo.calledWith('foo', 1); + privateFooStubbedInstance.foo.calledWith(); const clsFoo: sinon.SinonStub = stubInstance.foo; const privateFooFoo: sinon.SinonStub = privateFooStubbedInstance.foo; const clsBar: number = stubInstance.bar;