diff --git a/types/i18next/i18next-tests.ts b/types/i18next/i18next-tests.ts index 2d3f6d3b04..a96901cbb7 100644 --- a/types/i18next/i18next-tests.ts +++ b/types/i18next/i18next-tests.ts @@ -1,8 +1,3 @@ -/// -/// -/// -/// - import i18n = require("i18next"); i18n.init({ diff --git a/types/karma-chai-sinon/index.d.ts b/types/karma-chai-sinon/index.d.ts index 5f1395c583..70680f2ac7 100644 --- a/types/karma-chai-sinon/index.d.ts +++ b/types/karma-chai-sinon/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/tubalmartin/karma-chai-sinon // Definitions by: Václav Ostrožlík // Definitions: https://github.com/borisyankov/DefinitelyTyped +// TypeScript Version: 2.2 /// import Sinon = require("sinon"); diff --git a/types/sinon-as-promised/index.d.ts b/types/sinon-as-promised/index.d.ts index 5efe4df979..097e13a1a0 100644 --- a/types/sinon-as-promised/index.d.ts +++ b/types/sinon-as-promised/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/bendrucker/sinon-as-promised // Definitions by: igrayson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import * as s from "sinon"; diff --git a/types/sinon-chai/index.d.ts b/types/sinon-chai/index.d.ts index facf13cdce..3ed2304d7a 100644 --- a/types/sinon-chai/index.d.ts +++ b/types/sinon-chai/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/domenic/sinon-chai // Definitions by: Kazi Manzur Rashid , Jed Mao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// /// diff --git a/types/sinon-chrome/index.d.ts b/types/sinon-chrome/index.d.ts index cfb769fb7c..89434cf791 100644 --- a/types/sinon-chrome/index.d.ts +++ b/types/sinon-chrome/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/vitalets/sinon-chrome // Definitions by: Tim Perry // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 /// /// diff --git a/types/sinon-express-mock/index.d.ts b/types/sinon-express-mock/index.d.ts index 240d962687..695f443642 100644 --- a/types/sinon-express-mock/index.d.ts +++ b/types/sinon-express-mock/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/danawoodman/sinon-express-mock#readme // Definitions by: Jared Chapiewsky // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 import * as Sinon from "sinon"; diff --git a/types/sinon-mongoose/index.d.ts b/types/sinon-mongoose/index.d.ts index f2d15651e8..ac8397bf9e 100644 --- a/types/sinon-mongoose/index.d.ts +++ b/types/sinon-mongoose/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/underscopeio/sinon-mongoose // Definitions by: stevehipwell // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 import * as s from "sinon"; diff --git a/types/sinon-stub-promise/index.d.ts b/types/sinon-stub-promise/index.d.ts index ad188d0fc4..10fc8adf4c 100644 --- a/types/sinon-stub-promise/index.d.ts +++ b/types/sinon-stub-promise/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/substantial/sinon-stub-promise // Definitions by: Thiago Temple // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 /// diff --git a/types/sinon-test/index.d.ts b/types/sinon-test/index.d.ts index 151842cf8e..4cda8702a6 100644 --- a/types/sinon-test/index.d.ts +++ b/types/sinon-test/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/sinonjs/sinon-test // Definitions by: Francis Saul // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 import * as Sinon from 'sinon'; diff --git a/types/sinon/index.d.ts b/types/sinon/index.d.ts index 68692f6d52..a48df85258 100644 --- a/types/sinon/index.d.ts +++ b/types/sinon/index.d.ts @@ -6,6 +6,7 @@ // Nico Jansen // James Garbutt // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// 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 @@ -506,10 +507,46 @@ declare namespace Sinon { // Utility overridables interface SinonStatic { + /** + * Creates a new object with the given functions as the prototype and stubs all implemented functions. + * + * @param constructor Object or class to stub. + * @returns A stubbed version of the constructor. + * @remarks The given constructor function is not invoked. See also the stub API. + */ createStubInstance(constructor: any): any; + + /** + * Creates a new object with the given functions as the prototype and stubs all implemented functions. + * + * @type TType Type being stubbed. + * @param constructor Object or class to stub. + * @returns A stubbed version of the constructor. + * @remarks The given constructor function is not invoked. See also the stub API. + */ + createStubInstance(constructor: StubbableType): SinonStubbedInstance; + format(obj: any): string; restore(object: any): void; } + + /** + * Stubbed type of an object with members replaced by stubs. + * + * @type TType Type being stubbed. + */ + interface StubbableType { + new(...args: any[]): TType; + } + + /** + * An instance of a stubbed object type with members replaced by stubs. + * + * @type TType Object type being stubbed. + */ + type SinonStubbedInstance = { + [P in keyof TType]: SinonStub; + }; } declare const Sinon: Sinon.SinonStatic; diff --git a/types/sinon/sinon-tests.ts b/types/sinon/sinon-tests.ts index 177eb0e0dd..9184ec6808 100644 --- a/types/sinon/sinon-tests.ts +++ b/types/sinon/sinon-tests.ts @@ -231,6 +231,7 @@ class TestCreateStubInstance { } sinon.createStubInstance(TestCreateStubInstance).someTestMethod('some argument'); +sinon.createStubInstance(TestCreateStubInstance).someTestMethod('some argument'); function testGetCalls() { let double = sinon.spy((a: number) => a * 2);