TypeScript Definition (d.ts) for Q "noConflict ()"
I am currently working on a project where I am using the Q Library for promises with TypeScript.
The newest version of Q has a method Q.noConflict()
. I use the .d.ts file from the DefinitelyTyped repository for text input .
Does not support printing Q.noConflict()
. I tried for hours to rewrite typing to support this method, but with no success.
I would like to use code Like this:
var myQ = Q.noConflict();
Where myQ
has a type Q
. But in .d.ts Q is a module that has interfaces as well as functions. This means that I cannot just add something like this noConflict(): Q
.
Here's a schematic from the definition file (not the whole file, but with all the 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 all the code, but it would be nice to get some hints from people who have already written some .d.ts files.
source to share