[jasmine] make SpyObjMethodNames more strongly-typed

When a generic type argument is provided, require the method names array
to only include keys of the generic type argument and for the object
syntax, additionally require that the setup returned type matches the
return type of the method. Requires TS 2.8 for conditional types.
This commit is contained in:
Chris Yungmann 2018-10-26 12:11:17 -05:00
parent 33937378a6
commit 6b2775d9b4
18 changed files with 26 additions and 20 deletions

View File

@ -2,7 +2,7 @@
// Project: https://github.com/mgonto/angular-wizard
// Definitions by: Marko Jurisic <https://github.com/mjurisic>, Ronald Wildenberg <https://github.com/rwwilden>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
import * as angular from 'angular';

View File

@ -3,7 +3,7 @@
// Definitions by: Christopher E. Woodland <https://github.com/cwoodland>
// Johnny Li <https://github.com/johnny4753>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
// TypeScript Version: 2.8
/// <reference types='jasmine'/>

View File

@ -2,7 +2,7 @@
// Project: https://github.com/vlucas/frisby
// Definitions by: Johnny Li <https://github.com/johnny4753>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
///<reference types="jasmine"/>

View File

@ -2,7 +2,7 @@
// Project: https://github.com/sindresorhus/gulp-jasmine#readme
// Definitions by: Andrey Lalev <https://github.com/andypyrope>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/// <reference types="node" />
/// <reference types="jasmine" />

View File

@ -2,7 +2,7 @@
// Project: https://github.com/jasmine/jasmine-ajax
// Definitions by: Louis Grignon <https://github.com/lgrignon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
interface JasmineAjaxResponse {
status?: number;

View File

@ -2,7 +2,7 @@
// Project: https://github.com/gburghardt/jasmine-data_driven_tests
// Definitions by: Anthony MacKinnon <https://github.com/AnthonyMacKinnon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
declare var all: JasmineDataDrivenTest;
declare var xall: JasmineDataDrivenTest;

View File

@ -2,7 +2,7 @@
// Project: https://github.com/bvaughn/jasmine-es6-promise-matchers
// Definitions by: Stephen Lautier <https://github.com/stephenlautier>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/// <reference types="jasmine" />

View File

@ -2,7 +2,7 @@
// Project: https://github.com/searls/jasmine-fixture
// Definitions by: Craig Brett <https://github.com/craigbrett17>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/// <reference types="jasmine" />

View File

@ -2,7 +2,7 @@
// Project: https://github.com/velesin/jasmine-jquery
// Definitions by: Gregor Stamac <https://github.com/gstamac>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/// <reference types="jasmine"/>
/// <reference types="jquery"/>

View File

@ -2,7 +2,7 @@
// Project: https://github.com/uxebu/jasmine-matchers
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/*
Typings 2013 Bart van der Schoor

View File

@ -2,7 +2,7 @@
// Project: https://github.com/mhevery/jasmine-node
// Definitions by: Sven Reglitzki <https://github.com/svi3c>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
///<reference types="jasmine"/>

View File

@ -2,7 +2,7 @@
// Project: https://github.com/bvaughn/jasmine-promise-matchers
// Definitions by: Matthew Hill <https://github.com/matthewjh>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/// <reference types="jasmine" />

View File

@ -1,8 +1,14 @@
// Type definitions for Jasmine 2.8.0
// Project: http://jasmine.github.io/
// Definitions by: Boris Yankov <https://github.com/borisyankov>, Theodore Brown <https://github.com/theodorejb>, David Pärsson <https://github.com/davidparsson>, Gabe Moothart <https://github.com/gmoothart>, Lukas Zech <https://github.com/lukas-zech-software>, Boris Breuer <https://github.com/Engineer2B>
// Definitions by: Boris Yankov <https://github.com/borisyankov>
// Theodore Brown <https://github.com/theodorejb>
// David Pärsson <https://github.com/davidparsson>
// Gabe Moothart <https://github.com/gmoothart>
// Lukas Zech <https://github.com/lukas-zech-software>
// Boris Breuer <https://github.com/Engineer2B>
// Chris Yungmann <https://github.com/cyungmann>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
// For ddescribe / iit use : https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/karma-jasmine/karma-jasmine.d.ts
/**
@ -129,7 +135,7 @@ declare function waits(timeout?: number): void;
declare namespace jasmine {
type Expected<T> = T | ObjectContaining<T> | Any | Spy;
type SpyObjMethodNames<T = {}> = string[] | {[methodName: string]: any} | Array<keyof T>;
type SpyObjMethodNames<T = undefined> = T extends undefined ? (ReadonlyArray<string> | {[methodName: string]: any}) : (ReadonlyArray<keyof T> | {[P in keyof T]?: ReturnType<T[P] extends (...args: any[]) => any ? T[P] : any>});
var clock: () => Clock;

View File

@ -2,7 +2,7 @@
// Project: https://github.com/charleshansen/jasmine_dom_matchers
// Definitions by: Yaroslav Admin <https://github.com/devoto13>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/// <reference types="jasmine" />

View File

@ -3,7 +3,7 @@
// Definitions by: Sammy Jelin <https://github.com/sjelin>
// George Kalpakas <https://github.com/gkalpak>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/// <reference types="jasmine" />

View File

@ -2,7 +2,7 @@
// Project: https://github.com/karma-runner/karma-jasmine
// Definitions by: Michel Salib <https://github.com/michelsalib>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/// <reference types="jasmine" />

View File

@ -2,7 +2,7 @@
// Project: https://github.com/wix/protractor-helpers
// Definitions by: John Cant <https://github.com/johncant>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
import * as webdriver from "selenium-webdriver";

View File

@ -2,7 +2,7 @@
// Project: https://github.com/pushtechnology/saywhen
// Definitions by: Sean Sobey <https://github.com/SeanSobey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
/// <reference types="jasmine" />