Typescript definition to use Azure Mobile Services Client HTML/JS
library
You need an Azure subcription (even 3-month trial) to get valid
applicationUrl and applicationKey to use the library
- Make applicationHost parameter optional in setRoot
- Add missing activeRoute definition
- Add missing useConvention definition
- Add missing handleInvalidRoute definition
- Change mapRoute definition so you can pass an URL with all the other
parameters as you will usealy do or you pass a RouteInfo object without
having to give it any other parameter. moduleId, name and visible are
now optional.
The type definition for ng.IPromise.then was, in my opinion, incorrect
semantically, and breaking on practical examples in my codebase.
An `IPromise`' `then` function takes a callback which is called with the
value of the promise once it's fulfilled. This could be a number, a
string, some object, an array of strings, anything really. Yet the
typing in angular.d.ts specified `then` as taking a `successCallback` of
type `(response: PromiseCallbackArg) => any`.
The definition of `PromiseCallbackArg` seems very permissive at first
glance, as it is defined to be an object with a bunch of fields, all
optional. Any object, a number, and a string all type check correctly
with such a type, but an array of strings, for example, does not
(`cPromise` in the provided list of test).
Furthermore, it seems to me that the `PromiseCallbackArg` definition was
added specifically to support the response type for promises returned by
the Angular `$http` service, the `ng.IHttpPromise`.
So instead of having an incorrect type on the `ng.IPromise.then` function,
I propose we return it to its generic form, and instead override the
type of the inherited `then` function in the `ng.IHttpPromise` interface.
This would also warrant renaming `PromiseCallbackArg` to
`IHttpPromiseCallbackArg`.
logChange is an example of an extension, not part of the standard library. To add extensions, simply extend the interface outside of the definition file:
interface KnockoutExtenders {
logChange(target: KnockoutObservableAny, option: string): KnockoutObservableAny;
}