diff --git a/q/Q-tests.ts b/q/Q-tests.ts
index cd3cc653e..b04067003 100644
--- a/q/Q-tests.ts
+++ b/q/Q-tests.ts
@@ -1,6 +1,6 @@
///
-Q(8).then(x => console.log(x));
+Q(8).then(x => console.log(x.toExponential()));
var delay = function (delay) {
var d = Q.defer();
@@ -24,11 +24,11 @@ Q.when(x, function (x) {
Q.all([
eventually(10),
eventually(20)
-])
-.spread(function (x, y) {
+]).spread(function (x, y) {
console.log(x, y);
});
+
Q.fcall(function () { })
.then(function () { })
.then(function () { })
@@ -40,7 +40,7 @@ Q.fcall(function () { })
}).done();
Q.allResolved([])
-.then(function (promises: Q.Promise[]) {
+.then(function (promises: Q.Promise[]) {
promises.forEach(function (promise) {
if (promise.isFulfilled()) {
var value = promise.valueOf();
diff --git a/q/Q.d.ts b/q/Q.d.ts
index a0ecb75ce..25ed1b8e8 100644
--- a/q/Q.d.ts
+++ b/q/Q.d.ts
@@ -3,66 +3,67 @@
// Definitions by: Barrie Nemetchek, Andrew Gaspar
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-declare function Q(value: any): Q.Promise;
+declare function Q(value: T): Q.Promise;
+//declare function Q(value: Q.Promise): Q.Promise
declare module Q {
- interface Deferred {
- promise: Promise;
+ interface Deferred {
+ promise: Promise;
resolve(value: any): any;
reject(reason: any);
notify(value: any);
makeNodeResolver(): () => void;
}
- interface Promise {
- fail(errorCallback: Function): Promise;
- fin(finallyCallback: Function): Promise;
- then(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): Promise;
- spread(onFulfilled: Function, onRejected?: Function): Promise;
- catch(onRejected: Function): Promise;
- progress(onProgress: Function): Promise;
- done(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): Promise;
- get(propertyName: String): Promise;
- set(propertyName: String, value: any): Promise;
- delete(propertyName: String): Promise;
- post(methodName: String, args: any[]): Promise;
- invoke(methodName: String, ...args: any[]): Promise;
- keys(): Promise;
- fapply(args: any[]): Promise;
- fcall(method: Function, ...args: any[]): Promise;
- timeout(ms: number): Promise;
- delay(ms: number): Promise;
+ interface Promise {
+ fail(errorCallback: Function): Promise;
+ fin(finallyCallback: Function): Promise;
+ then(onFulfilled?: (value: T) => any, onRejected?: (reason) => any, onProgress?: Function): Promise;
+ spread(onFulfilled: Function, onRejected?: Function): Promise;
+ catch(onRejected: Function): Promise;
+ progress(onProgress: Function): Promise;
+ done(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): Promise;
+ get(propertyName: String): Promise;
+ set(propertyName: String, value: any): Promise;
+ delete(propertyName: String): Promise;
+ post(methodName: String, args: any[]): Promise;
+ invoke(methodName: String, ...args: any[]): Promise;
+ keys(): Promise;
+ fapply(args: any[]): Promise;
+ fcall(method: Function, ...args: any[]): Promise;
+ timeout(ms: number): Promise;
+ delay(ms: number): Promise;
isFulfilled(): bool;
isRejected(): bool;
isPending(): bool;
valueOf(): any;
}
- export function when(value: any, onFulfilled: Function, onRejected?: Function): Promise;
- //export function try(method: Function, ...args: any[]): Qpromise; <- This is broken currently - not sure how to fix.
- export function fbind(method: Function, ...args: any[]): Promise;
- export function fcall(method: Function, ...args: any[]): Promise;
- export function nfbind(nodeFunction: Function): (...args: any[]) => Promise;
- export function nfcall(nodeFunction: Function, ...args: any[]): Promise;
- export function ninvoke(nodeModule: any, functionName: string, ...args: any[]): Promise;
- export function all(promises: Promise[]): Promise;
- export function allResolved(promises: Promise[]): Promise;
- export function spread(onFulfilled: Function, onRejected: Function): Promise;
- export function timeout(ms: number): Promise;
- export function delay(ms: number): Promise;
- export function delay(value: any, ms: number): Promise;
+ export function when(value: any, onFulfilled: Function, onRejected?: Function): Promise;
+ //export function try(method: Function, ...args: any[]): Promise; // <- This is broken currently - not sure how to fix.
+ export function fbind(method: Function, ...args: any[]): Promise;
+ export function fcall(method: Function, ...args: any[]): Promise;
+ export function nfbind(nodeFunction: Function): (...args: any[]) => Promise;
+ export function nfcall(nodeFunction: Function, ...args: any[]): Promise;
+ export function ninvoke(nodeModule: any, functionName: string, ...args: any[]): Promise;
+ export function all(promises: Promise[]): Promise;
+ export function allResolved(promises: Promise[]): Promise;
+ export function spread(onFulfilled: Function, onRejected: Function): Promise;
+ export function timeout(ms: number): Promise;
+ export function delay(ms: number): Promise;
+ export function delay(value: any, ms: number): Promise;
export function isFulfilled(): bool;
export function isRejected(): bool;
export function isPending(): bool;
export function valueOf(): any;
export function defer(): Deferred;
- export function reject(): Promise;
- export function promise(factory: { resolve: Function; reject: Function; notify: Function; }): Promise;
+ export function reject(): Promise;
+ export function promise(factory: { resolve: Function; reject: Function; notify: Function; }): Promise;
export function isPromise(value: any): bool;
export function async(generatorFunction: any): Deferred;
export function nextTick(callback: Function);
export var oneerror: any;
export var longStackJumpLimit: number;
- export function resolve(object?: Promise);
+ export function resolve(object?: Promise);
}
declare module "q" {
diff --git a/q/q.module-tests.ts b/q/q.module-tests.ts
index fe4764e76..037dd028c 100644
--- a/q/q.module-tests.ts
+++ b/q/q.module-tests.ts
@@ -5,7 +5,7 @@
import q = module("q");
import fs = module("fs");
-q(8).then(x => console.log(x));
+q(8).then(x => console.log(x.toExponential()));
var delay = function (delay) {
var d = q.defer();
@@ -44,7 +44,7 @@ q.fcall(function () { })
// Handle any error from step1 through step4
}).done();
-q.allResolved([]).then(function (promises) {
+q.allResolved([]).then(function (promises: Q.Promise[]) {
promises.forEach(function (promise) {
if (promise.isFulfilled()) {
var value = promise.valueOf();