Typescript definition file for to$q
-
21-12-2019 - |
Question
I am hoping that I can get some help. I have been trying use to$q in an angular application that I am trying to describe using typescript. But I am struggling. I have tried to create a type definition file as follows:
/// <reference path="../q/Q.d.ts" />
/// <reference path="../angularjs/angular.d.ts" />
declare module breeze.core {
export function extendQ(rootScope: ng.IScope, q: Q.Promise<any>): any;
export function to$q(qPromise: Q.Promise<any>, success: any, fail: any): any;
}
But the javascript code is acting more like a c# extension method and I dont know how to achieve a similar affect with typescript. Note that I have only basic experience in javascript and that breeze is compleletely new to me.
Solution
That's good to know, @basarat.
But more important ... we have deprecated to$q
in favor of using $q
for promises throughout your Breeze app. That's right. Breeze no longer depends on Q.js (although that remains the default).
Please use Breeze.Angular.Q instead. It is available as a NuGet package or directly from GitHub. See the Breeze Labs documentation for it.
You simply configure Breeze to use the $q
instance for your app module and then write your breeze code against $q
promises. For example
var promise = entityManager
.executeQuery(query)
.then(successCallback)
.catch(failCallback)
.finally(finalCallback);
OTHER TIPS
$q is defined in angularjs type definitions here
You should not need to reference q.d.ts