From 4753cb27edd3ec639b46da8f1ac85884cc00e522 Mon Sep 17 00:00:00 2001 From: Benjamin Fox Date: Tue, 18 Jul 2017 10:26:14 +1200 Subject: [PATCH] Add basic method name type checking to sinon.spy and sinon.stub --- types/sinon/index.d.ts | 8 ++++---- types/sinon/sinon-tests.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 75e87baae1..30a64b9d81 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -96,8 +96,8 @@ declare namespace Sinon { interface SinonSpyStatic { (): SinonSpy; - (func: any): SinonSpy; - (obj: any, method: string): SinonSpy; + (func: Function): SinonSpy; + (obj: T, method: keyof T): SinonSpy; } interface SinonStatic { @@ -153,8 +153,8 @@ declare namespace Sinon { interface SinonStubStatic { (): SinonStub; (obj: any): SinonStub; - (obj: any, method: string): SinonStub; - (obj: any, method: string, func: any): SinonStub; + (obj: T, method: keyof T): SinonStub; + (obj: T, method: keyof T, func: Function): SinonStub; } interface SinonStatic { diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 406c790a2b..cd48901dd0 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -30,7 +30,7 @@ function testTwo() { function testThree() { let obj = { thisObj: true }; - let callback = sinon.spy({}, "method"); + let callback = sinon.spy({}, "method"); let proxy = once(callback); proxy.call(obj, callback, 1, 2, 3); if (callback.calledOn(obj)) { console.log("test3 calledOn success"); } else { console.log("test3 calledOn failure"); } @@ -168,7 +168,7 @@ function testSetMatcher() { } function testGetterStub() { - const myObj: any = { + const myObj = { prop: 'foo' }; @@ -177,7 +177,7 @@ function testGetterStub() { } function testSetterStub() { - const myObj: any = { + const myObj = { prop: 'foo', prop2: 'bar' }; @@ -187,7 +187,7 @@ function testSetterStub() { } function testValueStub() { - const myObj: any = { + const myObj = { prop: 'foo' };