I'm currently working an a project where I use the Q Library for promises with TypeScript.
The newest Version of Q has the method Q.noConflict()
.
For the typing I'm using the .d.ts File from the DefinitelyTyped Repository.
The typing does not support Q.noConflict()
. I tried several hours to rewrite the typing to support this method, but with no success.
I would like to use the code Like this:
var myQ = Q.noConflict();
Where myQ
is of Type Q
. But in the .d.ts Q is a module which has Interfaces as well as functions. That means I can't simply add something like this noConflict(): Q
.
Here is the schema from the definition file (not the whole file but with all relevant parts):
declare function Q(value: T): Q.Promise;
declare module Q {
interface IPromise<T> {
then<U>(onFulfill?: (value: T) => U | IPromise<U>, onReject?: (error: any) => U | IPromise<U>): IPromise<U>;
}
interface Deferred<T> {
promise: Promise<T>;
}
interface Promise<T> {
get<U>(propertyName: String): Promise<U>;
}
export function when(): Promise<void>;
export function resolve<T>(object: T): Promise<T>;
}
declare module "q" {
export = Q;
}
Of course I don't expect to get the whole code but it would be great the get some hints from people who have already written some .d.ts files.
Use
typeof Q
as the return type: