diff --git a/Q/Q.d.ts b/Q/Q.d.ts index f7a871ea4b..45af07fd23 100644 --- a/Q/Q.d.ts +++ b/Q/Q.d.ts @@ -8,7 +8,7 @@ interface Qdeferred { resolve(value: any): any; reject(reason: any); notify(value: any); - makeNodeResolver(); + makeNodeResolver(): Function; } interface Qpromise { diff --git a/Q/q.module-tests.ts b/Q/q.module-tests.ts new file mode 100644 index 0000000000..510a50610c --- /dev/null +++ b/Q/q.module-tests.ts @@ -0,0 +1,27 @@ +/// +/// + +import q = module("q"); + +describe("q", function () { + it("should return", function (done) { + q({ myValue: true }).then(function (obj) { + + if (obj.myValue) done(); + else done("didn't work =("); + }, + (err) => done(err)); + }); + + it("should process all", function (done: (err?) => void) { + q.all([q(1), q(2), q(3)]).then(function (arr: number[]) { + var sum = arr.reduce(function (memo, cur) { + return memo + cur; + }, 0); + + if (sum === 6) done(); + else done({ actual: sum }); + }, + (err) => done(err)); + }); +}); \ No newline at end of file diff --git a/Q/q.module.d.ts b/Q/q.module.d.ts new file mode 100644 index 0000000000..38b19aafc2 --- /dev/null +++ b/Q/q.module.d.ts @@ -0,0 +1,26 @@ +/// + +module "q" { + export function try(method: Function, ...args: any[]): Qpromise; + export function fbind(method: Function, ...args: any[]): Qpromise; + export function fcall(method: Function, ...args: any[]): Qpromise; + export function all(promises: Qpromise[]): Qpromise; + export function allResolved(promises: Qpromise[]): Qpromise; + export function spread(onFulfilled: Function, onRejected: Function): Qpromise; + export function timeout(ms: number): Qpromise; + export function delay(ms: number): Qpromise; + export function delay(value: any, ms: number): Qpromise; + export function isFulfilled(): bool; + export function isRejected(): bool; + export function isPending(): bool; + export function valueOf(): any; + export function defer(): Qdeferred; + export function (value: any): Qpromise; + export function reject(): Qpromise; + export function promise(factory: { resolve: Function; reject: Function; notify: Function; }): Qpromise; + export function isPromise(value: any): bool; + export function async(generatorFunction: any): Qdeferred; + export function nextTick(callback: Function); + export var oneerror: any; + export var longStackJumpLimit: number; +} \ No newline at end of file diff --git a/jasmine/jasmine.d.ts b/jasmine/jasmine.d.ts index 56f41b48f1..05e4370040 100644 --- a/jasmine/jasmine.d.ts +++ b/jasmine/jasmine.d.ts @@ -7,7 +7,8 @@ declare function describe(description: string, specDefinitions: Function): void; declare function xdescribe(description: string, specDefinitions: Function): void; -declare function it(expectation: string, assertion: Function): void; +declare function it(expectation: string, assertion: () => void ): void; +declare function it(expectation: string, assertion: (done: (err?) => void) => void ): void; declare function xit(expectation: string, assertion: Function): void; declare function beforeEach(action: Function): void;