From 5befd67eabb90ec9bd3308ca4319aae6d3c6ac08 Mon Sep 17 00:00:00 2001 From: Moshe Kolodny Date: Wed, 13 Mar 2019 21:57:19 -0400 Subject: [PATCH] Fix the build with a hack --- types/saywhen/saywhen-tests.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/types/saywhen/saywhen-tests.ts b/types/saywhen/saywhen-tests.ts index a253308156..3eb72825fe 100644 --- a/types/saywhen/saywhen-tests.ts +++ b/types/saywhen/saywhen-tests.ts @@ -1,7 +1,17 @@ import when = require('saywhen'); -when(jasmine.createSpy('test')); // $ExpectType CallHandler -when(jasmine.createSpy('test')).isCalled; // $ExpectType Proxy +// This interface is needed to get around the fact that the new jasmine +// `createSpy` method takes a generic type while the old typings don't. +// That means that in Typescript 3.0 the spy will be `Spy` and in 3.1 it +// will be `Spy`. This interface matches both and is +// what dtslint will expect the type to be. +interface JasmineSpy extends jasmine.Spy { + (...params: any[]): any; +} +const spy: JasmineSpy = jasmine.createSpy('test'); + +when(spy); // $ExpectType CallHandler +when(spy).isCalled; // $ExpectType Proxy when.captor(); // $ExpectType MatcherProxy<{}> when.captor(jasmine.any(Number)); // $ExpectType MatcherProxy