I believe your case requires a workaround. The definition file you have does not have export definitions of any type, so they cannot be extended outside of this file.
I assume you installed sinon through typings install sinon . If you do typings search sinon , there are actually 2, one from npm and one from dt . By default, npm definitions are set. This dt definition is as follows:
declare namespace Sinon { // ... interface SinonStub extends SinonSpy { // ... } // ... } declare var sinon: Sinon.SinonStatic; declare module "sinon" { export = sinon; }
There is also a dt entry for sinon-stub-promise , which goes well with the above:
declare namespace Sinon { interface SinonPromise { resolves(value?: any): void; rejects(value?: any): void; } interface SinonStub { returnsPromise(): SinonPromise; } }
So this is a workaround:
- Delete current
sinon . - Install TyptyTyped typings for
sinon : typings install sinon --source dt --global - Set TyptyTyped typings for
sinon-stub-promise : typings install sinon-stub-promise --source dt --global
Now this compiles successfully:
/// <reference path="typings/index.d.ts" /> import * as sinon from 'sinon'; sinon.stub().returnsPromise();
source share