Revert "Used a conditional type for Sinon's stub class typings (#25656)" (#25686)

This reverts commit 49ecfa4536.
This commit is contained in:
Andy
2018-05-10 13:24:02 -07:00
committed by Sheetal Nandi
parent f0b4609d77
commit 478994240a
12 changed files with 13 additions and 28 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/tubalmartin/karma-chai-sinon
// Definitions by: Václav Ostrožlík <https://github.com/vasek17>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
/// <reference types="chai" />
import Sinon = require("sinon");
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/pawelgalazka/mochaccino#readme
// Definitions by: Thomas-P <https://github.com/thomas-p>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import * as Sinon from "sinon";
export interface Expect {
not: Expect;
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/shouldjs/sinon
// Definitions by: AryloYeung <https://github.com/Arylo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import * as s from "sinon";
import should = require("should");
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/bendrucker/sinon-as-promised
// Definitions by: igrayson <https://github.com/igrayson>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import * as s from "sinon";
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/domenic/sinon-chai
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid>, Jed Mao <https://github.com/jedmao>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
/// <reference types="chai" />
/// <reference types="sinon" />
+1 -1
View File
@@ -4,7 +4,7 @@
// CRIMX <https://github.com/crimx>
// kobanyan <https://github.com/kobanyan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.4
/// <reference types="chrome"/>
/// <reference types="sinon"/>
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Jared Chapiewsky <https://github.com/jpchip>
// Tomek Łaziuk <https://github.com/tlaziuk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import {
SinonStub,
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/underscopeio/sinon-mongoose
// Definitions by: stevehipwell <https://github.com/stevehipwell>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import * as s from "sinon";
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Thiago Temple <https://github.com/vintem>
// Tim Stackhouse <https://github.com/tstackhouse>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
/// <reference types="sinon"/>
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/sinonjs/sinon-test
// Definitions by: Francis Saul <https://github.com/mummybot>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
import * as Sinon from 'sinon';
+3 -9
View File
@@ -5,9 +5,8 @@
// Lukas Spieß <https://github.com/lumaxis>
// Nico Jansen <https://github.com/nicojs>
// James Garbutt <https://github.com/43081j>
// Josh Goldberg <https://github.com/joshuakgoldberg>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// TypeScript Version: 2.3
// sinon uses DOM dependencies which are absent in browser-less environment like node.js
// to avoid compiler errors this monkey patch is used
@@ -567,20 +566,15 @@ declare namespace Sinon {
}
/**
* An instance of a stubbed object type with functions replaced by stubs.
* An instance of a stubbed object type with members replaced by stubs.
*
* @template TType Object type being stubbed.
*/
type SinonStubbedInstance<TType> = {
// TODO: this should really only replace functions on TType with SinonStubs, not all properties
// Likely infeasible without mapped conditional types, per https://github.com/Microsoft/TypeScript/issues/12424
[P in keyof TType]: SinonStubbedMember<TType[P]>;
[P in keyof TType]: SinonStub;
};
/**
* Replaces a type with a Sinon stub if it's a function.
*/
type SinonStubbedMember<T> = T extends Function ? SinonStub : T;
}
declare const Sinon: Sinon.SinonStatic;
-9
View File
@@ -154,15 +154,6 @@ function testSandbox() {
sandbox.createStubInstance<TestCreateStubInstance>(TestCreateStubInstance).someTestMethod('some argument');
}
class OneFunctionOneNumber {
memberFunction() { }
memberNumber: number;
}
const stubInstance = sinon.createStubInstance<OneFunctionOneNumber>(OneFunctionOneNumber);
const memberFunction: sinon.SinonStub = stubInstance.memberFunction;
const memberNumber: number = stubInstance.memberNumber;
function testPromises() {
let resolveStub = sinon.stub().resolves();
resolveStub = sinon.stub().resolves(10);