Merge pull request #4 from borisyankov/master

Update fork
This commit is contained in:
bluong
2014-11-13 17:12:10 -08:00
201 changed files with 41798 additions and 1792 deletions
+2
View File
@@ -33,3 +33,5 @@ _infrastructure/tests/build
!rx.js
node_modules
.sublimets
+2
View File
@@ -2,5 +2,7 @@ language: node_js
node_js:
- "0.10"
sudo: false
notifications:
email: false
+657 -427
View File
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
/// <reference path="headroom.d.ts" />
new Headroom(document.getElementById('siteHead'));
new Headroom(document.getElementsByClassName('siteHead')[0]);
new Headroom(document.getElementsByClassName('siteHead')[0], {
tolerance: 34
});
new Headroom(document.getElementsByClassName('siteHead')[0], {
offset: 500
});
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for headroom.js v0.7.0
// Project: http://wicky.nillia.ms/headroom.js/
// Definitions by: Jakub Olek <https://github.com/hakubo/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface HeadroomOptions {
offset?: number;
tolerance?: any;
classes?: {
initial?: string;
pinned?: string;
unpinned?: string;
top?: string;
notTop?: string;
};
scroller?: Element;
onPin?: () => void;
onUnPin?: () => void;
onTop?: () => void;
onNotTop?: () => void;
}
declare class Headroom {
constructor(element: Node, options?: HeadroomOptions);
constructor(element: Element, options?: HeadroomOptions);
init: () => void;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./tsc.js')
File diff suppressed because one or more lines are too long
+33
View File
@@ -0,0 +1,33 @@
/// <reference path="adm-zip.d.ts" />
import AdmZip = require("adm-zip");
// reading archives
var zip = new AdmZip("./my_file.zip");
var zipEntries = zip.getEntries(); // an array of ZipEntry records
zipEntries.forEach(function (zipEntry) {
console.log(zipEntry.toString()); // outputs zip entries information
if (zipEntry.entryName == "my_file.txt") {
console.log(zipEntry.getData().toString('utf8'));
}
});
// outputs the content of some_folder/my_file.txt
console.log(zip.readAsText("some_folder/my_file.txt"));
// extracts the specified file to the specified location
zip.extractEntryTo(/*entry name*/"some_folder/my_file.txt", /*target path*/"/home/me/tempfolder", /*overwrite*/true)
// extracts everything
zip.extractAllTo(/*target path*/"/home/me/zipcontent/", /*overwrite*/true);
// creating archives
var zip = new AdmZip();
// add file directly
zip.addFile("test.txt", new Buffer("inner content of the file"), "entry comment goes here");
// add local file
zip.addLocalFile("/home/me/some_picture.png");
// get everything as a buffer
var willSendthis = zip.toBuffer();
// or write everything to disk
zip.writeZip(/*target file name*/"/home/me/files.zip");
+300
View File
@@ -0,0 +1,300 @@
// Type definitions for adm-zip v0.4.4
// Project: https://github.com/cthackers/adm-zip
// Definitions by: John Vilk <https://github.com/jvilk>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module AdmZip {
class ZipFile {
/**
* Create a new, empty archive.
*/
constructor();
/**
* Read an existing archive.
*/
constructor(fileName: string);
/**
* Extracts the given entry from the archive and returns the content as a
* Buffer object.
* @param entry String with the full path of the entry
* @return Buffer or Null in case of error
*/
readFile(entry: string): Buffer;
/**
* Extracts the given entry from the archive and returns the content as a
* Buffer object.
* @param entry ZipEntry object
* @return Buffer or Null in case of error
*/
readFile(entry: IZipEntry): Buffer;
/**
* Asynchronous readFile
* @param entry String with the full path of the entry
* @param callback Called with a Buffer or Null in case of error
*/
readFileAsync(entry: string, callback: (data: Buffer, err: string) => any): void;
/**
* Asynchronous readFile
* @param entry ZipEntry object
* @param callback Called with a Buffer or Null in case of error
* @return Buffer or Null in case of error
*/
readFileAsync(entry: IZipEntry, callback: (data: Buffer, err: string) => any): void;
/**
* Extracts the given entry from the archive and returns the content as
* plain text in the given encoding
* @param entry String with the full path of the entry
* @param encoding Optional. If no encoding is specified utf8 is used
* @return String
*/
readAsText(fileName: string, encoding?: string): string;
/**
* Extracts the given entry from the archive and returns the content as
* plain text in the given encoding
* @param entry ZipEntry object
* @param encoding Optional. If no encoding is specified utf8 is used
* @return String
*/
readAsText(fileName: IZipEntry, encoding?: string): string;
/**
* Asynchronous readAsText
* @param entry String with the full path of the entry
* @param callback Called with the resulting string.
* @param encoding Optional. If no encoding is specified utf8 is used
*/
readAsTextAsync(fileName: string, callback: (data: string) => any, encoding?: string): void;
/**
* Asynchronous readAsText
* @param entry ZipEntry object
* @param callback Called with the resulting string.
* @param encoding Optional. If no encoding is specified utf8 is used
*/
readAsTextAsync(fileName: IZipEntry, callback: (data: string) => any, encoding?: string): void;
/**
* Remove the entry from the file or the entry and all its nested directories
* and files if the given entry is a directory
* @param entry String with the full path of the entry
*/
deleteFile(entry: string): void;
/**
* Remove the entry from the file or the entry and all its nested directories
* and files if the given entry is a directory
* @param entry A ZipEntry object.
*/
deleteFile(entry: IZipEntry): void;
/**
* Adds a comment to the zip. The zip must be rewritten after
* adding the comment.
* @param comment Content of the comment.
*/
addZipComment(comment: string): void;
/**
* Returns the zip comment
* @return The zip comment.
*/
getZipComment(): string;
/**
* Adds a comment to a specified zipEntry. The zip must be rewritten after
* adding the comment.
* The comment cannot exceed 65535 characters in length.
* @param entry String with the full path of the entry
* @param comment The comment to add to the entry.
*/
addZipEntryComment(entry: string, comment: string): void;
/**
* Adds a comment to a specified zipEntry. The zip must be rewritten after
* adding the comment.
* The comment cannot exceed 65535 characters in length.
* @param entry ZipEntry object.
* @param comment The comment to add to the entry.
*/
addZipEntryComment(entry: IZipEntry, comment: string): void;
/**
* Returns the comment of the specified entry.
* @param entry String with the full path of the entry.
* @return String The comment of the specified entry.
*/
getZipEntryComment(entry: string): string;
/**
* Returns the comment of the specified entry
* @param entry ZipEntry object.
* @return String The comment of the specified entry.
*/
getZipEntryComment(entry: IZipEntry): string;
/**
* Updates the content of an existing entry inside the archive. The zip
* must be rewritten after updating the content
* @param entry String with the full path of the entry.
* @param content The entry's new contents.
*/
updateFile(entry: string, content: Buffer): void;
/**
* Updates the content of an existing entry inside the archive. The zip
* must be rewritten after updating the content
* @param entry ZipEntry object.
* @param content The entry's new contents.
*/
updateFile(entry: IZipEntry, content: Buffer): void;
/**
* Adds a file from the disk to the archive.
* @param localPath Path to a file on disk.
* @param zipPath Path to a directory in the archive. Defaults to the empty
* string.
*/
addLocalFile(localPath: string, zipPath?: string): void;
/**
* Adds a local directory and all its nested files and directories to the
* archive.
* @param localPath Path to a folder on disk.
* @param zipPath Path to a folder in the archive. Defaults to an empty
* string.
*/
addLocalFolder(localPath: string, zipPath?: string): void;
/**
* Allows you to create a entry (file or directory) in the zip file.
* If you want to create a directory the entryName must end in / and a null
* buffer should be provided.
* @param entryName Entry path
* @param content Content to add to the entry; must be a 0-length buffer
* for a directory.
* @param comment Comment to add to the entry.
* @param attr Attribute to add to the entry.
*/
addFile(entryName: string, data: Buffer, comment?: string, attr?: number): void;
/**
* Returns an array of ZipEntry objects representing the files and folders
* inside the archive
*/
getEntries(): IZipEntry[];
/**
* Returns a ZipEntry object representing the file or folder specified by
* ``name``.
* @param name Name of the file or folder to retrieve.
* @return ZipEntry The entry corresponding to the name.
*/
getEntry(name: string): IZipEntry;
/**
* Extracts the given entry to the given targetPath.
* If the entry is a directory inside the archive, the entire directory and
* its subdirectories will be extracted.
* @param entry String with the full path of the entry
* @param targetPath Target folder where to write the file
* @param maintainEntryPath If maintainEntryPath is true and the entry is
* inside a folder, the entry folder will be created in targetPath as
* well. Default is TRUE
* @param overwrite If the file already exists at the target path, the file
* will be overwriten if this is true. Default is FALSE
*
* @return Boolean
*/
extractEntryTo(entryPath: string, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
/**
* Extracts the given entry to the given targetPath.
* If the entry is a directory inside the archive, the entire directory and
* its subdirectories will be extracted.
* @param entry ZipEntry object
* @param targetPath Target folder where to write the file
* @param maintainEntryPath If maintainEntryPath is true and the entry is
* inside a folder, the entry folder will be created in targetPath as
* well. Default is TRUE
* @param overwrite If the file already exists at the target path, the file
* will be overwriten if this is true. Default is FALSE
* @return Boolean
*/
extractEntryTo(entryPath: IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean;
/**
* Extracts the entire archive to the given location
* @param targetPath Target location
* @param overwrite If the file already exists at the target path, the file
* will be overwriten if this is true. Default is FALSE
*/
extractAllTo(targetPath: string, overwrite?: boolean): void;
/**
* Writes the newly created zip file to disk at the specified location or
* if a zip was opened and no ``targetFileName`` is provided, it will
* overwrite the opened zip
* @param targetFileName
*/
writeZip(targetPath?: string): void;
/**
* Returns the content of the entire zip file as a Buffer object
* @return Buffer
*/
toBuffer(): Buffer;
}
/**
* The ZipEntry is more than a structure representing the entry inside the
* zip file. Beside the normal attributes and headers a entry can have, the
* class contains a reference to the part of the file where the compressed
* data resides and decompresses it when requested. It also compresses the
* data and creates the headers required to write in the zip file.
*/
interface IZipEntry {
/**
* Represents the full name and path of the file
*/
entryName: string;
rawEntryName: Buffer;
/**
* Extra data associated with this entry.
*/
extra: Buffer;
/**
* Entry comment.
*/
comment: string;
name: string;
/**
* Read-Only property that indicates the type of the entry.
*/
isDirectory: boolean;
/**
* Get the header associated with this ZipEntry.
*/
header: Buffer;
/**
* Retrieve the compressed data for this entry. Note that this may trigger
* compression if any properties were modified.
*/
getCompressedData(): Buffer;
/**
* Asynchronously retrieve the compressed data for this entry. Note that
* this may trigger compression if any properties were modified.
*/
getCompressedDataAsync(callback: (data: Buffer) => void): void;
/**
* Set the (uncompressed) data to be associated with this entry.
*/
setData(value: string): void;
/**
* Set the (uncompressed) data to be associated with this entry.
*/
setData(value: Buffer): void;
/**
* Get the decompressed data associated with this entry.
*/
getData(): Buffer;
/**
* Asynchronously get the decompressed data associated with this entry.
*/
getDataAsync(callback: (data: Buffer) => void): void;
/**
* Returns the CEN Entry Header to be written to the output zip file, plus
* the extra data and the entry comment.
*/
packHeader(): Buffer;
/**
* Returns a nicely formatted string with the most important properties of
* the ZipEntry.
*/
toString(): string;
}
}
declare module "adm-zip" {
import zipFile = AdmZip.ZipFile;
export = zipFile;
}
+31
View File
@@ -0,0 +1,31 @@
/// <reference path="angular-notify.d.ts" />
var myapp = angular.module("myapp", ["cgNotify"]);
myapp.controller("MyController", ["$scope", "cgNotify",
function ($scope:ng.IScope, notify:ng.cgNotify.INotifyService) { // <-- Inject notify
var notifyObj = notify("Your notification message"); // <-- Call notify with your message
notifyObj.close();
notify.config({
startTop: 10,
verticalSpacing: 15,
duration: 10000,
templateUrl: "angular-notify.html",
position: "center",
container: document.body
});
notify( {
message: "My message",
templateUrl: "my_template.html",
position: "center",
container: document.body,
classes: "", // <-- CSS class names
$scope: $scope
}); // <-- Call notify with your message + option
notify.closeAll();
}
]);
+116
View File
@@ -0,0 +1,116 @@
// Type definitions for angular-notify 2.0.2
// Project: https://github.com/cgross/angular-notify
// Definitions by: Suwato <https://github.com/Suwato/DefinitelyTyped>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../angularjs/angular.d.ts" />
declare module ng.cgNotify {
interface INotifyService {
/**
* The notify function can either be passed a string or an object.
* This function will return an object with a close() method and a message property.
* @param message
*/
(message:string):INotify;
/**
* When passing an object, the object parameters can be:
* @param option
*/
(option:{
/**
* Required. The message to show.
*/
message : string;
/**
* Optional. A custom template for the UI of the message.
*/
templateUrl? : string;
/**
* Optional. A list of custom CSS classes to apply to the message element.
*/
classes? : string;
/**
* Optional. A string containing any valid Angular HTML which will be shown instead of the regular message text.
* The string must contain one root element like all valid Angular HTML templates (so wrap everything in a <span>).
*/
messageTemplate? : string;
/**
* Optional. A valid Angular scope object. The scope of the template will be created by calling $new() on this scope.
*/
$scope? : ng.IScope;
/**
* Optional. Currently center and right are the only acceptable values.
*/
position? : string;
/**
* Optional. Element that contains each notification. Defaults to document.body.
*/
container? : any;
}):INotify;
/**
* Call config to set the default configuration options for angular-notify.
* The following options may be specified in the given object:
* @param option
*/
config(option:{
/**
* The default duration (in milliseconds) of each message. A duration of 0 will prevent messages from closing automatically.
*/
duration? : number;
/**
* The Y pixel value where messages will be shown.
*/
startTop? : number;
/**
* The number of pixels that should be reserved between messages vertically.
*/
verticalSpacing? : number;
/**
* The default message template.
*/
templateUrl? : string;
/**
* The default position of each message. Currently only center and right are the supported values.
*/
position? : string;
/**
* The default element that contains each notification. Defaults to document.body.
*/
container? : any;
}):void;
/**
* Closes all currently open notifications.
*/
closeAll():void;
}
interface INotify{
/**
* The message to show.
*/
message:string;
/**
* Close this open notifications.
*/
close():void;
}
}
+152 -39
View File
@@ -3,53 +3,166 @@
var myapp = angular.module("myapp", ["firebase"]);
interface AngularFireScope extends ng.IScope {
items: AngularFire;
remoteItems: RemoteItems;
}
interface RemoteItems {
bar: string;
data: any;
}
var url = "https://myapp.firebaseio.com";
myapp.controller("MyController", ["$scope", "$firebase",
function($scope: AngularFireScope, $firebase: AngularFireService) {
$scope.items = $firebase(new Firebase(url));
$scope.items.$add({ foo: "bar" });
$scope.items.$remove("foo");
$scope.items.$remove();
$scope.items.$save();
var child = $scope.items.$child("foo");
child.$remove();
$scope.items.$set({ bar: "baz" });
var keys = $scope.items.$getIndex();
keys.forEach(function(key, i) {
console.log(i, (<any>$scope.items)[key]);
});
$scope.items.$on("loaded", function() {
console.log("Initial data received!");
});
$scope.items.$on("change", function() {
console.log("A remote change was applied locally!");
});
$scope.items.$off('loaded');
function stopSync() {
$scope.items.$off();
myapp.controller("MyController", ["$scope", "$firebase", '$FirebaseObject', '$FirebaseArray',
function ($scope: AngularFireScope, $firebase: AngularFireService, $FirebaseObject: AngularFireObjectService, $FirebaseArray: AngularFireArrayService) {
var ref = new Firebase(url);
var sync = $firebase(ref);
// AngularFire
{
sync.$asArray();
sync.$asObject();
sync.$ref();
sync.$remove();
sync.$push({ foo: "foo data" });
sync.$set("foo", 1);
sync.$set({ foo: 2 });
sync.$update({ foo: 3 });
sync.$update("foo", { bar: 1 });
// Increment the message count by 1
sync.$transaction('count', function (currentCount) {
if (!currentCount) return 1; // Initial value for counter.
if (currentCount < 0) return; // Return undefined to abort transaction.
return currentCount + 1; // Increment the count by 1.
}).then(function (snapshot) {
if (!snapshot) {
// Handle aborted transaction.
} else {
// Do something.
console.log(snapshot.val());
}
}, function (err) {
// Handle the error condition.
console.log(err.stack);
});
}
// AngularFireObject
{
var obj = sync.$asObject();
// $id
if (obj.$id !== ref.name()) throw "error";
// $loaded()
obj.$loaded().then((data) => {
if (data !== obj) throw "error";
// $priority
obj.$priority;
// $value, $save()
obj.$value = "foobar";
obj.$save();
});
// $inst()
if (obj.$inst() !== sync) throw "error";
// $bindTo()
obj.$bindTo($scope, "data").then(function () {
console.log($scope.data);
$scope.data.foo = "baz"; // will be saved to Firebase
sync.$set({ foo: "baz" }); // this would update Firebase and $scope.data
});
// $watch()
var unwatch = obj.$watch(function () {
console.log("data changed!");
});
unwatch();
// $destroy()
obj.$destroy();
// $extendFactory()
var NewFactory = $FirebaseObject.$extendFactory({
getMyFavoriteColor: function () {
return this.favoriteColor + ", no green!"; // obscure Monty Python reference
}
});
var customObj = $firebase(ref, { objectFactory: NewFactory }).$asObject();
}
// AngularFireArray
{
var list = sync.$asArray();
// $inst()
if (list.$inst() !== sync) throw "error";
// $add()
list.$add({ foo: "foo value" });
// $keyAt()
var key = list.$keyAt(0);
// $indexFor()
var index = list.$indexFor(key);
// $getRecord()
var item = list.$getRecord(key);
// $save()
item["bar"] = "bar value";
list.$save(item);
// $remove()
list.$remove(item);
// $loaded()
list.$loaded().then(data => {
if (data !== list) throw "error";
});
// $watch()
var unwatch = list.$watch((event, key, prevChild) => {
switch (event) {
case "child_added":
console.log(key + " added");
break;
case "child_changed":
console.log(key + " changed");
break;
case "child_moved":
console.log(key + " moved");
break;
case "child_removed":
console.log(key + " removed");
break;
default:
throw "error";
}
});
unwatch();
// $destroy()
list.$destroy();
// $extendFactory()
var ArrayWithSum = $FirebaseArray.$extendFactory({
sum: function () {
var total = 0;
angular.forEach(this.$list, function (rec) {
total += rec.x;
});
return total;
}
});
var list = $firebase(ref, { arrayFactory: ArrayWithSum }).$asArray();
list.$loaded().then(function () {
console.log("List has " + (<any>list).sum() + " items");
});
}
$scope.items.$bind($scope, "remoteItems");
$scope.remoteItems.bar = "foo";
$scope.items.$bind($scope, "remote").then(function(unbind) {
unbind();
$scope.remoteItems.bar = "foo";
});
}
]);
var foo: AngularFireObject = {
$priority: 0
};
interface AngularFireAuthScope extends ng.IScope {
loginObj: AngularFireAuth;
}
+55 -14
View File
@@ -1,4 +1,4 @@
// Type definitions for AngularFire 0.6.0
// Type definitions for AngularFire 0.8.2
// Project: http://angularfire.com
// Definitions by: Dénes Harmath <http://github.com/thSoft>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -7,24 +7,65 @@
/// <reference path="../firebase/firebase.d.ts"/>
interface AngularFireService {
(firebase: Firebase): AngularFire;
(firebase: Firebase, config?: any): AngularFire;
}
interface AngularFire {
$add(value: any): void;
$remove(key?: string): void;
$save(key?: string): void;
$child(key: string): AngularFire;
$set(value: any): void;
$getIndex(): string[];
$on(eventType: string, callback: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void;
$off(eventType?: string, callback?: (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void, cancelCallback?: ()=> void, context?: Object): (dataSnapshot: IFirebaseDataSnapshot, prevChildName?: string) => void;
$bind($scope: ng.IScope, modelName: string): ng.IPromise<any>;
$asArray(): AngularFireArray;
$asObject(): AngularFireObject;
$ref(): Firebase;
$push(data: any): ng.IPromise<Firebase>;
$set(key: string, data: any): ng.IPromise<Firebase>;
$set(data: any): ng.IPromise<Firebase>;
$remove(key?: string): ng.IPromise<Firebase>;
$update(key: string, data: Object): ng.IPromise<Firebase>;
$update(data: any): ng.IPromise<Firebase>;
$transaction(updateFn: (currentData: any) => any, applyLocally?: boolean): ng.IPromise<IFirebaseDataSnapshot>;
$transaction(key:string, updateFn: (currentData: any) => any, applyLocally?: boolean): ng.IPromise<IFirebaseDataSnapshot>;
}
interface AngularFireObject {
$priority: number;
interface AngularFireObject extends AngularFireSimpleObject {
$id: string;
$priority: number;
$value: any;
$save(): ng.IPromise<Firebase>;
$loaded(resolve?: (x: AngularFireObject) => ng.IHttpPromise<{}>, reject?: (err: any) => any): ng.IPromise<AngularFireObject>;
$loaded(resolve?: (x: AngularFireObject) => ng.IPromise<{}>, reject?: (err: any) => any): ng.IPromise<AngularFireObject>;
$loaded(resolve?: (x: AngularFireObject) => void, reject?: (err: any) => any): ng.IPromise<AngularFireObject>;
$inst(): AngularFire;
$bindTo(scope: ng.IScope, varName: string): ng.IPromise<any>;
$watch(callback: Function, context?: any): Function;
$destroy(): void;
}
interface AngularFireObjectService {
$extendFactory(ChildClass: Object, methods?: Object): Object;
}
interface AngularFireArray extends Array<AngularFireSimpleObject> {
$add(newData: any): ng.IPromise<Firebase>;
$save(recordOrIndex: any): ng.IPromise<Firebase>;
$remove(recordOrIndex: any): ng.IPromise<Firebase>;
$getRecord(key: string): AngularFireSimpleObject;
$keyAt(recordOrIndex: any): string;
$indexFor(key: string): number;
$loaded(resolve?: (x: AngularFireArray) => ng.IHttpPromise<{}>, reject?: (err: any) => any): ng.IPromise<AngularFireArray>;
$loaded(resolve?: (x: AngularFireArray) => ng.IPromise<{}>, reject?: (err: any) => any): ng.IPromise<AngularFireArray>;
$loaded(resolve?: (x: AngularFireArray) => void, reject?: (err: any) => any): ng.IPromise<AngularFireArray>;
$inst(): AngularFire;
$watch(cb: (event: string, key: string, prevChild: string) => void, context?: any): Function;
$destroy(): void;
}
interface AngularFireArrayService {
$extendFactory(ChildClass: Object, methods?: Object): Object;
}
interface AngularFireSimpleObject {
$id: string;
$priority: number;
$value: any;
[key: string]: any;
}
interface AngularFireAuthService {
(firebase: Firebase): AngularFireAuth;
@@ -34,7 +75,7 @@ interface AngularFireAuth {
$getCurrentUser(): ng.IPromise<any>;
$login(provider: string, options?: Object): ng.IPromise<any>;
$logout(): void;
$createUser(email: string, password: string, noLogin?: boolean): ng.IPromise<any>;
$createUser(email: string, password: string): ng.IPromise<any>;
$changePassword(email: string, oldPassword: string, newPassword: string): ng.IPromise<any>;
$removeUser(email: string, password: string): ng.IPromise<any>;
$sendPasswordResetEmail(email: string): ng.IPromise<any>;
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular JS 1.2+ (ngAnimate module)
// Type definitions for Angular JS 1.3 (ngAnimate module)
// Project: http://angularjs.org
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+4 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular JS 1.2 (ngCookies module)
// Type definitions for Angular JS 1.3 (ngCookies module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -15,7 +15,9 @@ declare module ng.cookies {
// CookieService
// see http://docs.angularjs.org/api/ngCookies.$cookies
///////////////////////////////////////////////////////////////////////////
interface ICookiesService {}
interface ICookiesService {
[index: string]: any;
}
///////////////////////////////////////////////////////////////////////////
// CookieStoreService
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module)
// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+20 -10
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular JS 1.2 (ngResource module)
// Type definitions for Angular JS 1.3 (ngResource module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
// Definitions: https://github.com/daptiv/DefinitelyTyped
@@ -11,6 +11,16 @@
///////////////////////////////////////////////////////////////////////////////
declare module ng.resource {
/**
* Currently supported options for the $resource factory options argument.
*/
interface IResourceOptions {
/**
* If true then the trailing slashes from any calculated URL will be stripped (defaults to true)
*/
stripTrailingSlashes?: boolean;
}
///////////////////////////////////////////////////////////////////////////
// ResourceService
// see http://docs.angularjs.org/api/ngResource.$resource
@@ -20,17 +30,17 @@ declare module ng.resource {
///////////////////////////////////////////////////////////////////////////
interface IResourceService {
(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actionDescriptors?: any): IResourceClass<IResource<any>>;
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actions?: any, options?: IResourceOptions): IResourceClass<IResource<any>>;
<T, U>(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actionDescriptors?: any): U;
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actions?: any, options?: IResourceOptions): U;
<T>(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actionDescriptors?: any): IResourceClass<T>;
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actions?: any, options?: IResourceOptions): IResourceClass<T>;
}
// Just a reference to facilitate describing new actions
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular JS 1.2 (ngRoute module)
// Type definitions for Angular JS 1.3 (ngRoute module)
// Project: http://angularjs.org
// Definitions by: Jonathan Park <https://github.com/park9140>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular JS 1.2 (ngSanitize module)
// Type definitions for Angular JS 1.3 (ngSanitize module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular Scenario Testing
// Type definitions for Angular Scenario Testing 1.3 (ngScenario module)
// Project: http://angularjs.org
// Definitions by: RomanoLindano <https://github.com/RomanoLindano>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+48 -1
View File
@@ -83,7 +83,7 @@ angular.module('http-auth-interceptor', [])
}
}];
$httpProvider.responseInterceptors.push(interceptor);
$httpProvider.interceptors.push(interceptor);
}]);
@@ -250,6 +250,12 @@ httpFoo.then((x) => {
x.toFixed();
});
httpFoo.success((data, status, headers, config) => {
var h = headers("test");
h.charAt(0);
var hs = headers();
hs["content-type"].charAt(1);
});
function test_angular_forEach() {
var values: { [key: string]: string } = { name: 'misko', gender: 'male' };
@@ -320,6 +326,47 @@ class SampleDirective2 implements ng.IDirective {
angular.module('SameplDirective', []).directive('sampleDirective', SampleDirective.instance).directive('sameplDirective2', SampleDirective2.instance);
angular.module('AnotherSampleDirective', []).directive('myDirective', ['$interpolate', '$q', ($interpolate: ng.IInterpolateService, $q: ng.IQService) => {
return {
restrict: 'A',
link: (scope: ng.IScope, el: ng.IAugmentedJQuery, attr: ng.IAttributes) => {
$interpolate(attr['test'])(scope);
$interpolate('', true)(scope);
$interpolate('', true, 'html')(scope);
$interpolate('', true, 'html', true)(scope);
var defer = $q.defer();
defer.reject();
defer.resolve();
defer.promise.then(function(d) {
return d;
}).then(function(): any {
return null;
}, function(): any {
return null;
})
.catch((): any => {
return null;
})
.finally((): any => {
return null;
});
var promise = new $q((resolve) => {
resolve();
});
promise = new $q((resolve, reject) => {
reject();
resolve(true);
});
promise = new $q<boolean>((resolver, reject) => {
resolver(true);
reject(false);
});
}
};
}]);
// test from https://docs.angularjs.org/guide/directive
angular.module('docsSimpleDirective', [])
.controller('Controller', ['$scope', function($scope: any) {
+108 -32
View File
@@ -13,6 +13,11 @@ interface Function {
$inject?: string[];
}
// Support AMD require
declare module 'angular' {
export = angular;
}
///////////////////////////////////////////////////////////////////////////////
// ng module (angular.js)
///////////////////////////////////////////////////////////////////////////////
@@ -32,6 +37,10 @@ declare module ng {
$get: any;
}
interface IAngularBootstrapConfig {
strictDi?: boolean;
}
///////////////////////////////////////////////////////////////////////////
// AngularStatic
// see http://docs.angularjs.org/api
@@ -46,8 +55,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: string, modules?: string): auto.IInjectorService;
bootstrap(element: string, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -55,8 +66,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: string, modules?: Function): auto.IInjectorService;
bootstrap(element: string, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -64,8 +77,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: string, modules?: string[]): auto.IInjectorService;
bootstrap(element: string, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -73,8 +88,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: JQuery, modules?: string): auto.IInjectorService;
bootstrap(element: JQuery, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -82,8 +99,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: JQuery, modules?: Function): auto.IInjectorService;
bootstrap(element: JQuery, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -91,8 +110,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: JQuery, modules?: string[]): auto.IInjectorService;
bootstrap(element: JQuery, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -100,8 +121,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: Element, modules?: string): auto.IInjectorService;
bootstrap(element: Element, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -109,8 +132,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: Element, modules?: Function): auto.IInjectorService;
bootstrap(element: Element, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -118,8 +143,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: Element, modules?: string[]): auto.IInjectorService;
bootstrap(element: Element, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -127,8 +154,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: Document, modules?: string): auto.IInjectorService;
bootstrap(element: Document, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -136,8 +165,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: Document, modules?: Function): auto.IInjectorService;
bootstrap(element: Document, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Use this function to manually start up angular application.
*
@@ -145,8 +176,10 @@ declare module ng {
* @param modules An array of modules to load into the application.
* Each item in the array should be the name of a predefined module or a (DI annotated)
* function that will be invoked by the injector as a run block.
* @param config an object for defining configuration options for the application. The following keys are supported:
* - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code.
*/
bootstrap(element: Document, modules?: string[]): auto.IInjectorService;
bootstrap(element: Document, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService;
/**
* Creates a deep copy of source, which should be an object or an array.
@@ -230,6 +263,7 @@ declare module ng {
configFn?: Function): IModule;
noop(...args: any[]): void;
reloadWithDebugInfo(): void;
toJson(obj: any, pretty?: boolean): string;
uppercase(str: string): string;
version: {
@@ -412,6 +446,7 @@ declare module ng {
$commitViewValue(): void;
$rollbackViewValue(): void;
$setSubmitted(): void;
$setUntouched(): void;
}
///////////////////////////////////////////////////////////////////////////
@@ -423,13 +458,13 @@ declare module ng {
$setValidity(validationErrorKey: string, isValid: boolean): void;
// Documentation states viewValue and modelValue to be a string but other
// types do work and it's common to use them.
$setViewValue(value: any): void;
$setViewValue(value: any, trigger?: string): void;
$setPristine(): void;
$validate(): void;
$setTouched(): void;
$setUntouched(): void;
$rollbackViewValue(): void;
$commitViewValue(revalidate?: boolean): void;
$commitViewValue(): void;
$isEmpty(value: any): boolean;
$viewValue: any;
@@ -448,6 +483,7 @@ declare module ng {
$validators: IModelValidators;
$asyncValidators: IAsyncModelValidators;
$pending: any;
$pristine: boolean;
$dirty: boolean;
$valid: boolean;
@@ -479,23 +515,31 @@ declare module ng {
* see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope
*/
interface IRootScopeService {
[index: string]: any;
$apply(): any;
$apply(exp: string): any;
$apply(exp: (scope: IScope) => any): any;
$applyAsync(): any;
$applyAsync(exp: string): any;
$applyAsync(exp: (scope: IScope) => any): any;
$broadcast(name: string, ...args: any[]): IAngularEvent;
$destroy(): void;
$digest(): void;
$emit(name: string, ...args: any[]): IAngularEvent;
$eval(expression?: string, args?: Object): any;
$eval(expression?: (scope: IScope) => any, args?: Object): any;
$eval(): any;
$eval(expression: string, locals?: Object): any;
$eval(expression: (scope: IScope) => any, locals?: Object): any;
$evalAsync(expression?: string): void;
$evalAsync(expression?: (scope: IScope) => any): void;
$evalAsync(): void;
$evalAsync(expression: string): void;
$evalAsync(expression: (scope: IScope) => any): void;
// Defaults to false by the implementation checking strategy
$new(isolate?: boolean): IScope;
$new(isolate?: boolean, parent?: IScope): IScope;
/**
* Listens on events of a given type. See $emit for discussion of event life cycle.
@@ -519,10 +563,7 @@ declare module ng {
$watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
$parent: IScope;
$root: IRootScopeService;
this: IRootScopeService;
$id: number;
// Hidden members
@@ -530,9 +571,7 @@ declare module ng {
$$phase: any;
}
interface IScope extends IRootScopeService {
[index: string]: any;
}
interface IScope extends IRootScopeService { }
interface IAngularEvent {
/**
@@ -700,8 +739,8 @@ declare module ng {
}
interface ILogProvider {
debugEnabled(enabled: boolean): ILogProvider;
debugEnabled(): boolean;
debugEnabled(enabled: boolean): ILogProvider;
}
// We define this as separete interface so we can reopen it later for
@@ -809,6 +848,8 @@ declare module ng {
*/
search(search: string, paramValue: boolean): ILocationService;
state(): any;
state(state: any): ILocationService;
url(): string;
url(url: string): ILocationService;
}
@@ -844,12 +885,20 @@ declare module ng {
///////////////////////////////////////////////////////////////////////////
interface IRootElementService extends JQuery {}
interface IQResolveReject<T> {
(): void;
(value: T): void;
}
/**
* $q - service in module ng
* A promise/deferred implementation inspired by Kris Kowal's Q.
* See http://docs.angularjs.org/api/ng/service/$q
*/
interface IQService {
new (resolver: (resolve: IQResolveReject<any>) => any): IPromise<any>;
new (resolver: (resolve: IQResolveReject<any>, reject: IQResolveReject<any>) => any): IPromise<any>;
new <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
/**
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
*
@@ -952,6 +1001,7 @@ declare module ng {
///////////////////////////////////////////////////////////////////////////
interface IAnchorScrollService {
(): void;
yOffset: any;
}
interface IAnchorScrollProvider extends IServiceProvider {
@@ -1011,6 +1061,8 @@ declare module ng {
imgSrcSanitizationWhitelist(): RegExp;
imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
debugInfoEnabled(enabled?: boolean): any;
}
interface ICloneAttachFunction {
@@ -1045,6 +1097,7 @@ declare module ng {
interface IControllerProvider extends IServiceProvider {
register(name: string, controllerConstructor: Function): void;
register(name: string, dependencyAnnotatedConstructor: any[]): void;
allowGlobals(): void;
}
/**
@@ -1200,8 +1253,13 @@ declare module ng {
url: string;
}
interface IHttpHeadersGetter {
(): { [name: string]: string; };
(headerName: string): string;
}
interface IHttpPromiseCallback<T> {
(data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): void;
(data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void;
}
interface IHttpPromiseCallbackArg<T> {
@@ -1219,10 +1277,22 @@ declare module ng {
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
}
interface IHttpProviderDefaults {
xsrfCookieName?: string;
xsrfHeaderName?: string;
headers?: {
common?: any;
post?: any;
put?: any;
patch?: any;
}
}
interface IHttpProvider extends IServiceProvider {
defaults: IRequestConfig;
defaults: IHttpProviderDefaults;
interceptors: any[];
responseInterceptors: any[];
useApplyAsync(): boolean;
useApplyAsync(value: boolean): IHttpProvider;
}
///////////////////////////////////////////////////////////////////////////
@@ -1241,7 +1311,7 @@ declare module ng {
// see http://docs.angularjs.org/api/ng.$interpolateProvider
///////////////////////////////////////////////////////////////////////////
interface IInterpolateService {
(text: string, mustHaveExpression?: boolean): IInterpolationFunction;
(text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction;
endSymbol(): string;
startSymbol(): string;
}
@@ -1337,6 +1407,11 @@ declare module ng {
* @return A promise whose value is the template content.
*/
(tpl: string, ignoreRequestError?: boolean): IPromise<string>;
/**
* total amount of pending template requests being downloaded.
* @type {number}
*/
totalPendingRequests: number;
}
///////////////////////////////////////////////////////////////////////////
@@ -1356,7 +1431,7 @@ declare module ng {
instanceAttributes: IAttributes,
controller: any,
transclude: ITranscludeFunction
): void;
): void;
}
interface IDirectivePrePost {
@@ -1369,13 +1444,14 @@ declare module ng {
templateElement: IAugmentedJQuery,
templateAttributes: IAttributes,
transclude: ITranscludeFunction
): IDirectivePrePost;
): IDirectivePrePost;
}
interface IDirective {
compile?: IDirectiveCompileFn;
controller?: any;
controllerAs?: string;
bindToController?: boolean;
link?: IDirectiveLinkFn;
name?: string;
priority?: number;
+7
View File
@@ -410,6 +410,13 @@ declare module ng {
cancel(promise: IPromise<any>): boolean;
}
/**
* The animation object which contains callback functions for each event that is expected to be animated.
*/
interface IAnimateCallbackObject {
eventFn(element: Node, doneFn: () => void): Function;
}
///////////////////////////////////////////////////////////////////////////
// FilterService
// see http://docs.angularjs.org/api/ng.$filter
+110
View File
@@ -0,0 +1,110 @@
// Type definitions for Angular JS 1.2 (ngAnimate module)
// Project: http://angularjs.org
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="angular-1.2.d.ts" />
///////////////////////////////////////////////////////////////////////////////
// ngAnimate module (angular-animate.js)
///////////////////////////////////////////////////////////////////////////////
declare module ng.animate {
///////////////////////////////////////////////////////////////////////////
// AnimateService
// see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/service/$animate
///////////////////////////////////////////////////////////////////////////
interface IAnimateService extends ng.IAnimateService {
/**
* Globally enables / disables animations.
*
* @param value If provided then set the animation on or off.
* @param element If provided then the element will be used to represent the enable/disable operation.
* @returns current animation state
*/
enabled(value?: boolean, element?: JQuery): boolean;
/**
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
*
* @param element the element that will be the focus of the enter animation
* @param parentElement the parent element of the element that will be the focus of the enter animation
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
* @param doneCallback the callback function that will be called once the animation is complete
*/
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void;
/**
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
*
* @param element the element that will be the focus of the leave animation
* @param doneCallback the callback function that will be called once the animation is complete
*/
leave(element: JQuery, doneCallback?: () => void): void;
/**
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
* it into the parentElement container or add the element directly after the afterElement element if present.
* Then the move animation will be run.
*
* @param element the element that will be the focus of the move animation
* @param parentElement the parent element of the element that will be the focus of the move animation
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
* @param doneCallback the callback function that will be called once the animation is complete
*/
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void;
/**
* Triggers a custom animation event based off the className variable and then attaches the className
* value to the element as a CSS class.
*
* @param element the element that will be animated
* @param className the CSS class that will be added to the element and then animated
* @param doneCallback the callback function that will be called once the animation is complete
*/
addClass(element: JQuery, className: string, doneCallback?: () => void): void;
/**
* Triggers a custom animation event based off the className variable and then removes the CSS class
* provided by the className value from the element.
*
* @param element the element that will be animated
* @param className the CSS class that will be animated and then removed from the element
* @param doneCallback the callback function that will be called once the animation is complete
*/
removeClass(element: JQuery, className: string, doneCallback?: () => void): void;
/**
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
* will be fired (if provided).
*
* @param element the element which will have its CSS classes changed removed from it
* @param add the CSS classes which will be added to the element
* @param remove the CSS class which will be removed from the element CSS classes have been set on the element
* @param doneCallback done the callback function (if provided) that will be fired after the CSS classes have been set on the element
*/
setClass(element: JQuery, add: string, remove: string, doneCallback?: () => void): void;
}
///////////////////////////////////////////////////////////////////////////
// AngularProvider
// see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/provider/$animateProvider
///////////////////////////////////////////////////////////////////////////
interface IAnimateProvider {
/**
* Registers a new injectable animation factory function.
*
* @param name The name of the animation.
* @param factory The factory function that will be executed to return the animation object.
*/
register(name: string, factory: () => ng.IAnimateCallbackObject): void;
/**
* Gets and/or sets the CSS class expression that is checked when performing an animation.
*
* @param expression The className expression which will be checked against all animations.
* @returns The current CSS className expression value. If null then there is no expression value.
*/
classNameFilter(expression?: RegExp): RegExp;
}
}
+43
View File
@@ -0,0 +1,43 @@
// Type definitions for Angular JS 1.2 (ngCookies module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="angular-1.2.d.ts" />
///////////////////////////////////////////////////////////////////////////////
// ngCookies module (angular-cookies.js)
///////////////////////////////////////////////////////////////////////////////
declare module ng.cookies {
///////////////////////////////////////////////////////////////////////////
// CookieService
// see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookies
///////////////////////////////////////////////////////////////////////////
interface ICookiesService {}
///////////////////////////////////////////////////////////////////////////
// CookieStoreService
// see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookieStore
///////////////////////////////////////////////////////////////////////////
interface ICookieStoreService {
/**
* Returns the value of given cookie key
* @param key Id to use for lookup
*/
get(key: string): any;
/**
* Sets a value for given cookie key
* @param key Id for the value
* @param value Value to be stored
*/
put(key: string, value: any): void;
/**
* Remove given cookie
* @param key Id of the key-value pair to delete
*/
remove(key: string): void;
}
}
+305
View File
@@ -0,0 +1,305 @@
/// <reference path="angular-mocks-1.2.d.ts" />
///////////////////////////////////////
// IAngularStatic
///////////////////////////////////////
var angular: ng.IAngularStatic;
var mock: ng.IMockStatic;
mock = angular.mock;
///////////////////////////////////////
// IMockStatic
///////////////////////////////////////
var date: Date;
mock.dump({ key: 'value' });
mock.inject(
function () { return 1; },
function () { return 2; }
);
mock.inject(
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }]);
// This overload is not documented on the website, but flows from
// how the injector works.
mock.inject(
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }],
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 2; }]);
mock.module('module1', 'module2');
mock.module(
function () { return 1; },
function () { return 2; }
);
mock.module({ module1: function () { return 1; } });
date = mock.TzDate(-7, '2013-1-1T15:00:00Z');
date = mock.TzDate(-8, 12345678);
///////////////////////////////////////
// IExceptionHandlerProvider
///////////////////////////////////////
var exceptionHandlerProvider: ng.IExceptionHandlerProvider;
exceptionHandlerProvider.mode('log');
///////////////////////////////////////
// ITimeoutService
///////////////////////////////////////
var timeoutService: ng.ITimeoutService;
timeoutService.flush();
timeoutService.flush(1234);
timeoutService.flushNext();
timeoutService.flushNext(1234);
timeoutService.verifyNoPendingTasks();
////////////////////////////////////////
// IIntervalService
////////////////////////////////////////
var intervalService: ng.IIntervalService;
var intervalServiceTimeActuallyAdvanced: number;
intervalServiceTimeActuallyAdvanced = intervalService.flush();
intervalServiceTimeActuallyAdvanced = intervalService.flush(1234);
///////////////////////////////////////
// ILogService, ILogCall
///////////////////////////////////////
var logService: ng.ILogService;
var logCall: ng.ILogCall;
var logs: string[];
logService.assertEmpty();
logService.reset();
logCall = logService.debug;
logCall = logService.error;
logCall = logService.info;
logCall = logService.log;
logCall = logService.warn;
logs = logCall.logs;
///////////////////////////////////////
// IHttpBackendService
///////////////////////////////////////
var httpBackendService: ng.IHttpBackendService;
var requestHandler: ng.mock.IRequestHandler;
httpBackendService.flush();
httpBackendService.flush(1234);
httpBackendService.resetExpectations();
httpBackendService.verifyNoOutstandingExpectation();
httpBackendService.verifyNoOutstandingRequest();
requestHandler = httpBackendService.expect('GET', 'http://test.local');
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data');
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', { header: 'value' });
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/);
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, { header: 'value' });
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; });
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' });
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.expect('GET', /test.local/);
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data');
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', { header: 'value' });
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/);
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, { header: 'value' });
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; });
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' });
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.expectDELETE('http://test.local');
requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' });
requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' });
requestHandler = httpBackendService.expectGET('http://test.local');
requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' });
requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' });
requestHandler = httpBackendService.expectHEAD('http://test.local');
requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' });
requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' });
requestHandler = httpBackendService.expectJSONP('http://test.local');
requestHandler = httpBackendService.expectJSONP(/test.local/);
requestHandler = httpBackendService.expectPATCH('http://test.local');
requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data');
requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data', { header: 'value' });
requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/);
requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/, { header: 'value' });
requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; });
requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' });
requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.expectPATCH(/test.local/);
requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data');
requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data', { header: 'value' });
requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/);
requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/, { header: 'value' });
requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; });
requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' });
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.expectPOST('http://test.local');
requestHandler = httpBackendService.expectPOST('http://test.local', 'response data');
requestHandler = httpBackendService.expectPOST('http://test.local', 'response data', { header: 'value' });
requestHandler = httpBackendService.expectPOST('http://test.local', /response data/);
requestHandler = httpBackendService.expectPOST('http://test.local', /response data/, { header: 'value' });
requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; });
requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' });
requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.expectPOST(/test.local/);
requestHandler = httpBackendService.expectPOST(/test.local/, 'response data');
requestHandler = httpBackendService.expectPOST(/test.local/, 'response data', { header: 'value' });
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/);
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' });
requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; });
requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' });
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.expectPUT('http://test.local');
requestHandler = httpBackendService.expectPUT('http://test.local', 'response data');
requestHandler = httpBackendService.expectPUT('http://test.local', 'response data', { header: 'value' });
requestHandler = httpBackendService.expectPUT('http://test.local', /response data/);
requestHandler = httpBackendService.expectPUT('http://test.local', /response data/, { header: 'value' });
requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; });
requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' });
requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.expectPUT(/test.local/);
requestHandler = httpBackendService.expectPUT(/test.local/, 'response data');
requestHandler = httpBackendService.expectPUT(/test.local/, 'response data', { header: 'value' });
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/);
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' });
requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; });
requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' });
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.when('GET', 'http://test.local');
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data');
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', { header: 'value' });
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/);
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, { header: 'value' });
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; });
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' });
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.when('GET', /test.local/);
requestHandler = httpBackendService.when('GET', /test.local/, 'response data');
requestHandler = httpBackendService.when('GET', /test.local/, 'response data', { header: 'value' });
requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.when('GET', /test.local/, /response data/);
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' });
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; });
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' });
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
requestHandler = httpBackendService.whenDELETE('http://test.local');
requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' });
requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' });
requestHandler = httpBackendService.whenGET('http://test.local');
requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' });
requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' });
requestHandler = httpBackendService.whenHEAD('http://test.local');
requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' });
requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' });
requestHandler = httpBackendService.whenJSONP('http://test.local');
requestHandler = httpBackendService.whenJSONP(/test.local/);
requestHandler = httpBackendService.whenPATCH('http://test.local');
requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data');
requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data', { header: 'value' });
requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/);
requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/, { header: 'value' });
requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; });
requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' });
requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.whenPATCH(/test.local/);
requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data');
requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data', { header: 'value' });
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/);
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' });
requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; });
requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' });
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.whenPOST('http://test.local');
requestHandler = httpBackendService.whenPOST('http://test.local', 'response data');
requestHandler = httpBackendService.whenPOST('http://test.local', 'response data', { header: 'value' });
requestHandler = httpBackendService.whenPOST('http://test.local', /response data/);
requestHandler = httpBackendService.whenPOST('http://test.local', /response data/, { header: 'value' });
requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; });
requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' });
requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.whenPOST(/test.local/);
requestHandler = httpBackendService.whenPOST(/test.local/, 'response data');
requestHandler = httpBackendService.whenPOST(/test.local/, 'response data', { header: 'value' });
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/);
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' });
requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; });
requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' });
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.whenPUT('http://test.local');
requestHandler = httpBackendService.whenPUT('http://test.local', 'response data');
requestHandler = httpBackendService.whenPUT('http://test.local', 'response data', { header: 'value' });
requestHandler = httpBackendService.whenPUT('http://test.local', /response data/);
requestHandler = httpBackendService.whenPUT('http://test.local', /response data/, { header: 'value' });
requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; });
requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' });
requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }, { header: 'value' });
requestHandler = httpBackendService.whenPUT(/test.local/);
requestHandler = httpBackendService.whenPUT(/test.local/, 'response data');
requestHandler = httpBackendService.whenPUT(/test.local/, 'response data', { header: 'value' });
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/);
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' });
requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; });
requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' });
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' });
///////////////////////////////////////
// IRequestHandler
///////////////////////////////////////
requestHandler.passThrough();
requestHandler.respond(function () { });
requestHandler.respond({ key: 'value' });
requestHandler.respond({ key: 'value' }, { header: 'value' });
requestHandler.respond(404);
requestHandler.respond(404, { key: 'value' });
requestHandler.respond(404, { key: 'value' }, { header: 'value' });
+226
View File
@@ -0,0 +1,226 @@
// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="angular-1.2.d.ts" />
///////////////////////////////////////////////////////////////////////////////
// functions attached to global object (window)
///////////////////////////////////////////////////////////////////////////////
declare var module: (...modules: any[]) => any;
declare var inject: (...fns: Function[]) => any;
///////////////////////////////////////////////////////////////////////////////
// ngMock module (angular-mocks.js)
///////////////////////////////////////////////////////////////////////////////
declare module ng {
///////////////////////////////////////////////////////////////////////////
// AngularStatic
// We reopen it to add the MockStatic definition
///////////////////////////////////////////////////////////////////////////
interface IAngularStatic {
mock: IMockStatic;
}
interface IMockStatic {
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.dump
dump(obj: any): string;
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.inject
inject(...fns: Function[]): any;
inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.module
module(...modules: any[]): any;
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/type/angular.mock.TzDate
TzDate(offset: number, timestamp: number): Date;
TzDate(offset: number, timestamp: string): Date;
}
///////////////////////////////////////////////////////////////////////////
// ExceptionHandlerService
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$exceptionHandler
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/provider/$exceptionHandlerProvider
///////////////////////////////////////////////////////////////////////////
interface IExceptionHandlerProvider extends IServiceProvider {
mode(mode: string): void;
}
///////////////////////////////////////////////////////////////////////////
// TimeoutService
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$timeout
// Augments the original service
///////////////////////////////////////////////////////////////////////////
interface ITimeoutService {
flush(delay?: number): void;
flushNext(expectedDelay?: number): void;
verifyNoPendingTasks(): void;
}
///////////////////////////////////////////////////////////////////////////
// IntervalService
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$interval
// Augments the original service
///////////////////////////////////////////////////////////////////////////
interface IIntervalService {
flush(millis?: number): number;
}
///////////////////////////////////////////////////////////////////////////
// LogService
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$log
// Augments the original service
///////////////////////////////////////////////////////////////////////////
interface ILogService {
assertEmpty(): void;
reset(): void;
}
interface ILogCall {
logs: string[];
}
///////////////////////////////////////////////////////////////////////////
// HttpBackendService
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$httpBackend
///////////////////////////////////////////////////////////////////////////
interface IHttpBackendService {
flush(count?: number): void;
resetExpectations(): void;
verifyNoOutstandingExpectation(): void;
verifyNoOutstandingRequest(): void;
expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
expectDELETE(url: string, headers?: Object): mock.IRequestHandler;
expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
expectGET(url: string, headers?: Object): mock.IRequestHandler;
expectGET(url: RegExp, headers?: Object): mock.IRequestHandler;
expectHEAD(url: string, headers?: Object): mock.IRequestHandler;
expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
expectJSONP(url: string): mock.IRequestHandler;
expectJSONP(url: RegExp): mock.IRequestHandler;
expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
whenDELETE(url: string, headers?: Object): mock.IRequestHandler;
whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
whenGET(url: string, headers?: Object): mock.IRequestHandler;
whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
whenGET(url: RegExp, headers?: Object): mock.IRequestHandler;
whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
whenHEAD(url: string, headers?: Object): mock.IRequestHandler;
whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
whenJSONP(url: string): mock.IRequestHandler;
whenJSONP(url: RegExp): mock.IRequestHandler;
whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
}
export module mock {
// returned interface by the the mocked HttpBackendService expect/when methods
interface IRequestHandler {
respond(func: Function): void;
respond(status: number, data?: any, headers?: any): void;
respond(data: any, headers?: any): void;
// Available wehn ngMockE2E is loaded
passThrough(): void;
}
}
}
@@ -0,0 +1,138 @@
/// <reference path="angular-resource-1.2.d.ts" />
interface IMyResource extends ng.resource.IResource<IMyResource> { };
interface IMyResourceClass extends ng.resource.IResourceClass<IMyResource> { };
///////////////////////////////////////
// IActionDescriptor
///////////////////////////////////////
var actionDescriptor: ng.resource.IActionDescriptor;
actionDescriptor.headers = { header: 'value' };
actionDescriptor.isArray = true;
actionDescriptor.method = 'method action';
actionDescriptor.params = { key: 'value' };
///////////////////////////////////////
// IResourceClass
///////////////////////////////////////
var resourceClass: IMyResourceClass;
var resource: IMyResource;
var resourceArray: ng.resource.IResourceArray<IMyResource>;
resource = resourceClass.delete();
resource = resourceClass.delete({ key: 'value' });
resource = resourceClass.delete({ key: 'value' }, function () { });
resource = resourceClass.delete(function () { });
resource = resourceClass.delete(function () { }, function () { });
resource = resourceClass.delete({ key: 'value' }, { key: 'value' });
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { });
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { });
resource.$promise.then(function(data: IMyResource) {});
resource = resourceClass.get();
resource = resourceClass.get({ key: 'value' });
resource = resourceClass.get({ key: 'value' }, function () { });
resource = resourceClass.get(function () { });
resource = resourceClass.get(function () { }, function () { });
resource = resourceClass.get({ key: 'value' }, { key: 'value' });
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { });
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { });
resourceArray = resourceClass.query();
resourceArray = resourceClass.query({ key: 'value' });
resourceArray = resourceClass.query({ key: 'value' }, function () { });
resourceArray = resourceClass.query(function () { });
resourceArray = resourceClass.query(function () { }, function () { });
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' });
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { });
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { });
resourceArray.push(resource);
resourceArray.$promise.then(function(data: ng.resource.IResourceArray<IMyResource>) {});
resource = resourceClass.remove();
resource = resourceClass.remove({ key: 'value' });
resource = resourceClass.remove({ key: 'value' }, function () { });
resource = resourceClass.remove(function () { });
resource = resourceClass.remove(function () { }, function () { });
resource = resourceClass.remove({ key: 'value' }, { key: 'value' });
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { });
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { });
resource = resourceClass.save();
resource = resourceClass.save({ key: 'value' });
resource = resourceClass.save({ key: 'value' }, function () { });
resource = resourceClass.save(function () { });
resource = resourceClass.save(function () { }, function () { });
resource = resourceClass.save({ key: 'value' }, { key: 'value' });
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { });
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { });
///////////////////////////////////////
// IResource
///////////////////////////////////////
var promise : ng.IPromise<IMyResource>;
var arrayPromise : ng.IPromise<IMyResource[]>;
promise = resource.$delete();
promise = resource.$delete({ key: 'value' });
promise = resource.$delete({ key: 'value' }, function () { });
promise = resource.$delete(function () { });
promise = resource.$delete(function () { }, function () { });
promise = resource.$delete({ key: 'value' }, function () { }, function () { });
promise.then(function(data: IMyResource) {});
promise = resource.$get();
promise = resource.$get({ key: 'value' });
promise = resource.$get({ key: 'value' }, function () { });
promise = resource.$get(function () { });
promise = resource.$get(function () { }, function () { });
promise = resource.$get({ key: 'value' }, function () { }, function () { });
arrayPromise = resourceArray[0].$query();
arrayPromise = resourceArray[0].$query({ key: 'value' });
arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { });
arrayPromise = resourceArray[0].$query(function () { });
arrayPromise = resourceArray[0].$query(function () { }, function () { });
arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }, function () { });
arrayPromise.then(function(data: ng.resource.IResourceArray<IMyResource>) {});
promise = resource.$remove();
promise = resource.$remove({ key: 'value' });
promise = resource.$remove({ key: 'value' }, function () { });
promise = resource.$remove(function () { });
promise = resource.$remove(function () { }, function () { });
promise = resource.$remove({ key: 'value' }, function () { }, function () { });
promise = resource.$save();
promise = resource.$save({ key: 'value' });
promise = resource.$save({ key: 'value' }, function () { });
promise = resource.$save(function () { });
promise = resource.$save(function () { }, function () { });
promise = resource.$save({ key: 'value' }, function () { }, function () { });
///////////////////////////////////////
// IResourceService
///////////////////////////////////////
var resourceService: ng.resource.IResourceService;
resourceClass = resourceService<IMyResource, IMyResourceClass>('test');
resourceClass = resourceService<IMyResource>('test');
resourceClass = resourceService('test');
///////////////////////////////////////
// IModule
///////////////////////////////////////
var mod: ng.IModule;
var resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction<IMyResource>;
var resourceService: ng.resource.IResourceService;
resourceClass = resourceServiceFactoryFunction<IMyResourceClass>(resourceService);
resourceServiceFactoryFunction = function (resourceService: ng.resource.IResourceService) { return <any>resourceClass; };
mod = mod.factory('factory name', resourceServiceFactoryFunction);
///////////////////////////////////////
// IResource
///////////////////////////////////////
+152
View File
@@ -0,0 +1,152 @@
// Type definitions for Angular JS 1.2 (ngResource module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
// Definitions: https://github.com/daptiv/DefinitelyTyped
/// <reference path="angular-1.2.d.ts" />
///////////////////////////////////////////////////////////////////////////////
// ngResource module (angular-resource.js)
///////////////////////////////////////////////////////////////////////////////
declare module ng.resource {
///////////////////////////////////////////////////////////////////////////
// ResourceService
// see https://code.angularjs.org/1.2.26/docs/api/ngResource/service/$resource
// Most of the following definitions were achieved by analyzing the
// actual implementation, since the documentation doesn't seem to cover
// that deeply.
///////////////////////////////////////////////////////////////////////////
interface IResourceService {
(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actionDescriptors?: any): IResourceClass<IResource<any>>;
<T, U>(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actionDescriptors?: any): U;
<T>(url: string, paramDefaults?: any,
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
where deleteDescriptor : IActionDescriptor */
actionDescriptors?: any): IResourceClass<T>;
}
// Just a reference to facilitate describing new actions
interface IActionDescriptor {
method: string;
isArray?: boolean;
params?: any;
headers?: any;
}
// Baseclass for everyresource with default actions.
// If you define your new actions for the resource, you will need
// to extend this interface and typecast the ResourceClass to it.
//
// In case of passing the first argument as anything but a function,
// it's gonna be considered data if the action method is POST, PUT or
// PATCH (in other words, methods with body). Otherwise, it's going
// to be considered as parameters to the request.
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465
//
// Only those methods with an HTTP body do have 'data' as first parameter:
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463
// More specifically, those methods are POST, PUT and PATCH:
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432
//
// Also, static calls always return the IResource (or IResourceArray) retrieved
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549
interface IResourceClass<T> {
new(dataOrParams? : any) : T;
get(): T;
get(params: Object): T;
get(success: Function, error?: Function): T;
get(params: Object, success: Function, error?: Function): T;
get(params: Object, data: Object, success?: Function, error?: Function): T;
query(): IResourceArray<T>;
query(params: Object): IResourceArray<T>;
query(success: Function, error?: Function): IResourceArray<T>;
query(params: Object, success: Function, error?: Function): IResourceArray<T>;
query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray<T>;
save(): T;
save(data: Object): T;
save(success: Function, error?: Function): T;
save(data: Object, success: Function, error?: Function): T;
save(params: Object, data: Object, success?: Function, error?: Function): T;
remove(): T;
remove(params: Object): T;
remove(success: Function, error?: Function): T;
remove(params: Object, success: Function, error?: Function): T;
remove(params: Object, data: Object, success?: Function, error?: Function): T;
delete(): T;
delete(params: Object): T;
delete(success: Function, error?: Function): T;
delete(params: Object, success: Function, error?: Function): T;
delete(params: Object, data: Object, success?: Function, error?: Function): T;
}
// Instance calls always return the the promise of the request which retrieved the object
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546
interface IResource<T> {
$get(): ng.IPromise<T>;
$get(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
$get(success: Function, error?: Function): ng.IPromise<T>;
$query(): ng.IPromise<IResourceArray<T>>;
$query(params?: Object, success?: Function, error?: Function): ng.IPromise<IResourceArray<T>>;
$query(success: Function, error?: Function): ng.IPromise<IResourceArray<T>>;
$save(): ng.IPromise<T>;
$save(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
$save(success: Function, error?: Function): ng.IPromise<T>;
$remove(): ng.IPromise<T>;
$remove(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
$remove(success: Function, error?: Function): ng.IPromise<T>;
$delete(): ng.IPromise<T>;
$delete(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
$delete(success: Function, error?: Function): ng.IPromise<T>;
/** the promise of the original server interaction that created this instance. **/
$promise : ng.IPromise<T>;
$resolved : boolean;
}
/**
* Really just a regular Array object with $promise and $resolve attached to it
*/
interface IResourceArray<T> extends Array<T> {
/** the promise of the original server interaction that created this collection. **/
$promise : ng.IPromise<IResourceArray<T>>;
$resolved : boolean;
}
/** when creating a resource factory via IModule.factory */
interface IResourceServiceFactoryFunction<T> {
($resource: ng.resource.IResourceService): IResourceClass<T>;
<U extends IResourceClass<T>>($resource: ng.resource.IResourceService): U;
}
}
/** extensions to base ng based on using angular-resource */
declare module ng {
interface IModule {
/** creating a resource service factory */
factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction<any>): IModule;
}
}
interface Array<T>
{
/** the promise of the original server interaction that created this collection. **/
$promise : ng.IPromise<Array<T>>;
$resolved : boolean;
}
@@ -0,0 +1,17 @@
/// <reference path="angular-route-1.2.d.ts" />
/**
* @license HTTP Auth Interceptor Module for AngularJS
* (c) 2013 Jonathan Park @ Daptiv Solutions Inc
* License: MIT
*/
declare var $routeProvider: ng.route.IRouteProvider;
$routeProvider
.when('/projects/:projectId/dashboard',{
controller: '',
templateUrl: '',
caseInsensitiveMatch: true,
reloadOnSearch: false
})
.otherwise({redirectTo: '/'});
+145
View File
@@ -0,0 +1,145 @@
// Type definitions for Angular JS 1.2 (ngRoute module)
// Project: http://angularjs.org
// Definitions by: Jonathan Park <https://github.com/park9140>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="angular-1.2.d.ts" />
///////////////////////////////////////////////////////////////////////////////
// ngRoute module (angular-route.js)
///////////////////////////////////////////////////////////////////////////////
declare module ng.route {
///////////////////////////////////////////////////////////////////////////
// RouteParamsService
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$routeParams
///////////////////////////////////////////////////////////////////////////
interface IRouteParamsService {
[key: string]: any;
}
///////////////////////////////////////////////////////////////////////////
// RouteService
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider
///////////////////////////////////////////////////////////////////////////
interface IRouteService {
/**
* Causes $route service to reload the current route even if $location hasn't changed.
* As a result of that, ngView creates new scope, reinstantiates the controller.
*/
reload(): void;
/**
* Object with all route configuration Objects as its properties.
*/
routes: any;
// May not always be available. For instance, current will not be available
// to a controller that was not initialized as a result of a route maching.
current?: ICurrentRoute;
}
/**
* see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider#when for API documentation
*/
interface IRoute {
/**
* {(string|function()=}
* Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string.
*/
controller?: any;
/**
* A controller alias name. If present the controller will be published to scope under the controllerAs name.
*/
controllerAs?: string;
/**
* Undocumented?
*/
name?: string;
/**
* {string=|function()=}
* Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl.
*
* If template is a function, it will be called with the following parameters:
*
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
*/
template?: string;
/**
* {string=|function()=}
* Path or function that returns a path to an html template that should be used by ngView.
*
* If templateUrl is a function, it will be called with the following parameters:
*
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
*/
templateUrl?: any;
/**
* {Object.<string, function>=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is:
*
* - key - {string}: a name of a dependency to be injected into the controller.
* - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead.
*/
resolve?: {[key: string]: any};
/**
* {(string|function())=}
* Value to update $location path with and trigger route redirection.
*
* If redirectTo is a function, it will be called with the following parameters:
*
* - {Object.<string>} - route parameters extracted from the current $location.path() by applying the current route templateUrl.
* - {string} - current $location.path()
* - {Object} - current $location.search()
* - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search().
*/
redirectTo?: any;
/**
* Reload route when only $location.search() or $location.hash() changes.
*
* This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope.
*/
reloadOnSearch?: boolean;
/**
* Match routes without being case sensitive
*
* This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
*/
caseInsensitiveMatch?: boolean;
}
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route#current
interface ICurrentRoute extends IRoute {
locals: {
$scope: IScope;
$template: string;
};
params: any;
}
interface IRouteProvider extends IServiceProvider {
/**
* Sets route definition that will be used on route change when no other route definition is matched.
*
* @params Mapping information to be assigned to $route.current.
*/
otherwise(params: IRoute): IRouteProvider;
/**
* Adds a new route definition to the $route service.
*
* @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition.
*
* - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches.
* - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches.
* - path can contain optional named groups with a question mark: e.g.:name?.
*
* For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes.
*
* @param route Mapping information to be assigned to $route.current on route match.
*/
when(path: string, route: IRoute): IRouteProvider;
}
}
@@ -0,0 +1,10 @@
/// <reference path="angular-sanitize-1.2.d.ts" />
var shouldBeString: string;
declare var $sanitizeService: ng.sanitize.ISanitizeService;
shouldBeString = $sanitizeService(shouldBeString);
declare var $linky: ng.sanitize.filter.ILinky;
shouldBeString = $linky(shouldBeString);
shouldBeString = $linky(shouldBeString, shouldBeString);
+35
View File
@@ -0,0 +1,35 @@
// Type definitions for Angular JS 1.2 (ngSanitize module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="angular-1.2.d.ts" />
///////////////////////////////////////////////////////////////////////////////
// ngSanitize module (angular-sanitize.js)
///////////////////////////////////////////////////////////////////////////////
declare module ng.sanitize {
///////////////////////////////////////////////////////////////////////////
// SanitizeService
// see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/service/$sanitize
///////////////////////////////////////////////////////////////////////////
interface ISanitizeService {
(html: string): string;
}
///////////////////////////////////////////////////////////////////////////
// Filters included with the ngSanitize
// see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter
///////////////////////////////////////////////////////////////////////////
export module filter {
// Finds links in text input and turns them into html links.
// Supports http/https/ftp/mailto and plain email address links.
// see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter/linky
interface ILinky {
(text: string, target?: string): string;
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular Scenario Testing
// Type definitions for Angular Scenario Testing 1.0 (ngScenario module)
// Project: [http://angularjs.org]
// Definitions by: [RomanoLindano]
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+166
View File
@@ -0,0 +1,166 @@
// Type definitions for Angular Scenario Testing 1.2 (ngScenario module)
// Project: http://angularjs.org
// Definitions by: RomanoLindano <https://github.com/RomanoLindano>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../../jquery/jquery.d.ts" />
declare module ng {
export interface IAngularStatic {
scenario: any;
}
}
declare module angularScenario {
export interface RunFunction {
(functionToRun: any): any;
}
export interface RunFunctionWithDescription {
(description: string, functionToRun: any): any;
}
export interface PauseFunction {
(): any;
}
export interface SleepFunction {
(seconds: number): any;
}
export interface Future {
}
export interface testWindow {
href(): Future;
path(): Future;
search(): Future;
hash(): Future;
}
export interface testLocation {
url(): Future;
path(): Future;
search(): Future;
hash(): Future;
}
export interface Browser {
navigateTo(url: string): void;
navigateTo(urlDescription: string, urlFunction: () => string): void;
reload(): void;
window(): testWindow;
location(): testLocation;
}
export interface Matchers {
toEqual(value: any): void;
toBe(value: any): void;
toBeDefined(): void;
toBeTruthy(): void;
toBeFalsy(): void;
toMatch(regularExpression: any): void;
toBeNull(): void;
toContain(value: any): void;
toBeLessThan(value: any): void;
toBeGreaterThan(value: any): void;
}
export interface CustomMatchers extends Matchers {
}
export interface Expect extends CustomMatchers {
not(): angularScenario.CustomMatchers;
}
export interface UsingFunction {
(selector: string, selectorDescription?: string): void;
}
export interface BindingFunction {
(bracketBindingExpression: string): Future;
}
export interface Input {
enter(value: any): any;
check(): any;
select(radioButtonValue: any): any;
val(): Future;
}
export interface Repeater {
count(): Future;
row(index: number): Future;
column(ngBindingExpression: string): Future;
}
export interface Select {
option(value: any): any;
option(...listOfValues: any[]): any;
}
export interface Element {
count(): Future;
click(): any;
dblclick(): any;
mouseover(): any;
mousedown(): any;
mouseup(): any;
query(callback: (selectedDOMElements: JQuery, callbackWhenDone: (objNull: any, futureValue: any) => any) => any): any;
val(): Future;
text(): Future;
html(): Future;
height(): Future;
innerHeight(): Future;
outerHeight(): Future;
width(): Future;
innerWidth(): Future;
outerWidth(): Future;
position(): Future;
scrollLeft(): Future;
scrollTop(): Future;
offset(): Future;
val(value: any): void;
text(value: any): void;
html(value: any): void;
height(value: any): void;
innerHeight(value: any): void;
outerHeight(value: any): void;
width(value: any): void;
innerWidth(value: any): void;
outerWidth(value: any): void;
position(value: any): void;
scrollLeft(value: any): void;
scrollTop(value: any): void;
offset(value: any): void;
attr(key: any): Future;
prop(key: any): Future;
css(key: any): Future;
attr(key: any, value: any): void;
prop(key: any, value: any): void;
css(key: any, value: any): void;
}
}
declare var describe: angularScenario.RunFunctionWithDescription;
declare var ddescribe: angularScenario.RunFunctionWithDescription;
declare var xdescribe: angularScenario.RunFunctionWithDescription;
declare var beforeEach: angularScenario.RunFunction;
declare var afterEach: angularScenario.RunFunction;
declare var it: angularScenario.RunFunctionWithDescription;
declare var iit: angularScenario.RunFunctionWithDescription;
declare var xit: angularScenario.RunFunctionWithDescription;
declare var pause: angularScenario.PauseFunction;
declare var sleep: angularScenario.SleepFunction;
declare function browser(): angularScenario.Browser;
declare function expect(expectation: angularScenario.Future): angularScenario.Expect;
declare var using: angularScenario.UsingFunction;
declare var binding: angularScenario.BindingFunction;
declare function input(ngModelBinding: string): angularScenario.Input;
declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater;
declare function select(ngModelBinding: string): angularScenario.Select;
declare function element(selector: string, elementDescription?: string): angularScenario.Element;
declare var angular: ng.IAngularStatic;
+1
View File
@@ -57,6 +57,7 @@ declare module assert {
// export = assert;
// }
// move to power-assert.d.ts. do not use this definition file.
declare module "power-assert" {
export = assert;
}
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for assertion-error 1.0 0
// Type definitions for assertion-error 1.0.0
// Project: https://github.com/chaijs/assertion-error
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+882
View File
@@ -0,0 +1,882 @@
/// <reference path="bluebird-1.0.d.ts" />
// Tests by: Bart van der Schoor <https://github.com/Bartvds>
// Note: replicate changes to all overloads in both definition and test file
// Note: keep both static and instance members inline (so similar)
// Note: try to maintain the ordering and separators, and keep to the pattern
var obj: Object;
var bool: boolean;
var num: number;
var str: string;
var err: Error;
var x: any;
var f: Function;
var func: Function;
var arr: any[];
var exp: RegExp;
var anyArr: any[];
var strArr: string[];
var numArr: number[];
// - - - - - - - - - - - - - - - - -
var value: any;
var reason: any;
var insanity: any;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
interface Foo {
foo(): string;
}
interface Bar {
bar(): string;
}
// - - - - - - - - - - - - - - - - -
interface StrFooMap {
[key:string]:Foo;
}
interface StrBarMap {
[key:string]:Bar;
}
// - - - - - - - - - - - - - - - - -
interface StrFooArrMap {
[key:string]:Foo[];
}
interface StrBarArrMap {
[key:string]:Bar[];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var foo: Foo;
var bar: Bar;
var fooArr: Foo[];
var barArr: Bar[];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var numProm: Promise<number>;
var strProm: Promise<string>;
var anyProm: Promise<any>;
var boolProm: Promise<boolean>;
var objProm: Promise<Object>;
var voidProm: Promise<void>;
var fooProm: Promise<Foo>;
var barProm: Promise<Bar>;
// - - - - - - - - - - - - - - - - -
var numThen: Promise.Thenable<number>;
var strThen: Promise.Thenable<string>;
var anyThen: Promise.Thenable<any>;
var boolThen: Promise.Thenable<boolean>;
var objThen: Promise.Thenable<Object>;
var voidThen: Promise.Thenable<void>;
var fooThen: Promise.Thenable<Foo>;
var barThen: Promise.Thenable<Bar>;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var numArrProm: Promise<number[]>;
var strArrProm: Promise<string[]>;
var anyArrProm: Promise<any[]>;
var fooArrProm: Promise<Foo[]>;
var barArrProm: Promise<Bar[]>;
// - - - - - - - - - - - - - - - - -
var numArrThen: Promise.Thenable<number[]>;
var strArrThen: Promise.Thenable<string[]>;
var anyArrThen: Promise.Thenable<any[]>;
var fooArrThen: Promise.Thenable<Foo[]>;
var barArrThen: Promise.Thenable<Bar[]>;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
var numPromArr: Promise<number>[];
var strPromArr: Promise<string>[];
var anyPromArr: Promise<any>[];
var fooPromArr: Promise<Foo>[];
var barPromArr: Promise<Bar>[];
// - - - - - - - - - - - - - - - - -
var numThenArr: Promise.Thenable<number>[];
var strThenArr: Promise.Thenable<string>[];
var anyThenArr: Promise.Thenable<any>[];
var fooThenArr: Promise.Thenable<Foo>[];
var barThenArr: Promise.Thenable<Bar>[];
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// booya!
var fooThenArrThen: Promise.Thenable<Promise.Thenable<Foo>[]>;
var barThenArrThen: Promise.Thenable<Promise.Thenable<Bar>[]>;
var fooResolver: Promise.Resolver<Foo>;
var barResolver: Promise.Resolver<Bar>;
var fooInspection: Promise.Inspection<Foo>;
var barInspection: Promise.Inspection<Bar>;
var fooInspectionArrProm: Promise<Promise.Inspection<Foo>[]>;
var barInspectionArrProm: Promise<Promise.Inspection<Bar>[]>;
var BlueBird: typeof Promise;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooThen = fooProm;
barThen = barProm;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = new Promise((resolve: (value: Foo) => void, reject: (reason: any) => void) => {
if (bool) {
resolve(foo);
}
else {
reject(new Error(str));
}
});
fooProm = new Promise((resolve: (value: Foo) => void) => {
if (bool) {
resolve(foo);
}
});
// - - - - - - - - - - - - - - - - - - - - - - -
// needs a hint when used untyped?
fooProm = new Promise<Foo>((resolve, reject) => {
if (bool) {
resolve(fooThen);
}
else {
reject(new Error(str));
}
});
fooProm = new Promise<Foo>((resolve) => {
resolve(fooThen);
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooResolver.resolve(foo);
fooResolver.reject(err);
fooResolver.progress(bar);
fooResolver.callback = (err: any, value: Foo) => {
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool = fooInspection.isFulfilled();
bool = fooInspection.isRejected();
bool = fooInspection.isPending();
foo = fooInspection.value();
x = fooInspection.error();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.then((value: Foo) => {
return bar;
}, (reason: any) => {
return bar;
}, (note: any) => {
return bar;
});
barProm = fooProm.then((value: Foo) => {
return bar;
}, (reason: any) => {
return bar;
});
barProm = fooProm.then((value: Foo) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.catch((reason: any) => {
return bar;
});
barProm = fooProm.caught((reason: any) => {
return bar;
});
barProm = fooProm.catch((reason: any) => {
return bar;
}, (reason: any) => {
return bar;
});
barProm = fooProm.caught((reason: any) => {
return bar;
}, (reason: any) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.catch(Error, (reason: any) => {
return bar;
});
barProm = fooProm.caught(Error, (reason: any) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.error((reason: any) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.finally((value: Foo) => {
// return is ignored
return foo;
});
fooProm = fooProm.finally((value: Foo) => {
// return is ignored
return fooThen;
});
fooProm = fooProm.finally((value: Foo) => {
// return is ignored
});
fooProm = fooProm.finally(() => {
// return is ignored
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.lastly((value: Foo) => {
// return is ignored
return foo;
});
fooProm = fooProm.lastly((value: Foo) => {
// return is ignored
return fooThen;
});
fooProm = fooProm.lastly((value: Foo) => {
// return is ignored
});
fooProm = fooProm.lastly(() => {
// return is ignored
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.bind(obj);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.done((value: Foo) => {
return bar;
}, (reason: any) => {
return bar;
}, (note: any) => {
});
barProm = fooProm.done((value: Foo) => {
return bar;
}, (reason: any) => {
return bar;
});
barProm = fooProm.done((value: Foo) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.done((value: Foo) => {
return barThen;
}, (reason: any) => {
return barThen;
}, (note: any) => {
});
barProm = fooProm.done((value: Foo) => {
return barThen;
}, (reason: any) => {
return barThen;
});
barProm = fooProm.done((value: Foo) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.progressed((note: any) => {
return foo;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.delay(num);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.timeout(num);
fooProm = fooProm.timeout(num, str);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm.nodeify();
fooProm = fooProm.nodeify((err: any) => {
});
fooProm = fooProm.nodeify((err: any, foo?: Foo) => {
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.fork((value: Foo) => {
return bar;
}, (reason: any) => {
return bar;
}, (note: any) => {
});
barProm = fooProm.fork((value: Foo) => {
return bar;
}, (reason: any) => {
return bar;
});
barProm = fooProm.fork((value: Foo) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.fork((value: Foo) => {
return barThen;
}, (reason: any) => {
return barThen;
}, (note: any) => {
});
barProm = fooProm.fork((value: Foo) => {
return barThen;
}, (reason: any) => {
return barThen;
});
barProm = fooProm.fork((value: Foo) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.cancel<Bar>();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.cancellable();
fooProm = fooProm.uncancellable();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool = fooProm.isCancellable();
bool = fooProm.isFulfilled();
bool = fooProm.isRejected();
bool = fooProm.isPending();
bool = fooProm.isResolved();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooInspection = fooProm.inspect();
anyProm = fooProm.call(str);
anyProm = fooProm.call(str, 1, 2, 3);
//TODO enable get() test when implemented
// barProm = fooProm.get(str);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.return(bar);
barProm = fooProm.thenReturn(bar);
voidProm = fooProm.return();
voidProm = fooProm.thenReturn();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooProm
fooProm = fooProm.throw(err);
fooProm = fooProm.thenThrow(err);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
str = fooProm.toString();
obj = fooProm.toJSON();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
return bar;
}, (reason: any) => {
return bar;
});
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
return bar;
});
// - - - - - - - - - - - - - - - - -
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar) => {
return barThen;
}, (reason: any) => {
return barThen;
});
barProm = fooArrProm.spread<Bar>((one: Foo, two: Bar, twotwo: Foo) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO fix collection inference
barArrProm = fooProm.all<Bar>();
objProm = fooProm.props();
barInspectionArrProm = fooProm.settle<Bar>();
barProm = fooProm.any<Bar>();
barArrProm = fooProm.some<Bar>(num);
barProm = fooProm.race<Bar>();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO fix collection inference
barArrProm = fooProm.map<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = fooProm.map<Foo, Bar>((item: Foo) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.reduce<Foo, Bar>((memo: Bar, item: Foo, index: number, arrayLength: number) => {
return memo;
});
barProm = fooProm.reduce<Foo, Bar>((memo: Bar, item: Foo) => {
return memo;
}, bar);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooArrProm = fooArrProm.filter<Foo>((item: Foo, index: number, arrayLength: number) => {
return bool;
});
fooArrProm = fooArrProm.filter<Foo>((item: Foo) => {
return bool;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = Promise.try(() => {
return foo;
});
fooProm = Promise.try(() => {
return foo;
}, arr);
fooProm = Promise.try(() => {
return foo;
}, arr, x);
// - - - - - - - - - - - - - - - - -
fooProm = Promise.try(() => {
return fooThen;
});
fooProm = Promise.try(() => {
return fooThen;
}, arr);
fooProm = Promise.try(() => {
return fooThen;
}, arr, x);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = Promise.attempt(() => {
return foo;
});
fooProm = Promise.attempt(() => {
return foo;
}, arr);
fooProm = Promise.attempt(() => {
return foo;
}, arr, x);
// - - - - - - - - - - - - - - - - -
fooProm = Promise.attempt(() => {
return fooThen;
});
fooProm = Promise.attempt(() => {
return fooThen;
}, arr);
fooProm = Promise.attempt(() => {
return fooThen;
}, arr, x);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func = Promise.method(function () {
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = Promise.resolve(foo);
fooProm = Promise.resolve(fooThen);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
voidProm = Promise.reject(reason);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooResolver = Promise.defer<Foo>();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = Promise.cast(foo);
fooProm = Promise.cast(fooThen);
voidProm = Promise.bind(x);
bool = Promise.is(value);
Promise.longStackTraces();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO enable delay
fooProm = Promise.delay(fooThen, num);
fooProm = Promise.delay(foo, num);
voidProm = Promise.delay(num);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
func = Promise.promisify(f);
func = Promise.promisify(f, obj);
;
obj = Promise.promisifyAll(obj);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO enable generator
/*
func = Promise.coroutine(f);
barProm = Promise.spawn<number>(f);
*/
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BlueBird = Promise.noConflict();
Promise.onPossiblyUnhandledRejection((reason: any) => {
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO expand tests to overloads
fooArrProm = Promise.all(fooThenArrThen);
fooArrProm = Promise.all(fooArrProm);
fooArrProm = Promise.all(fooThenArr);
fooArrProm = Promise.all(fooArr);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
objProm = Promise.props(objProm);
objProm = Promise.props(obj);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO expand tests to overloads
fooInspectionArrProm = Promise.settle(fooThenArrThen);
fooInspectionArrProm = Promise.settle(fooArrProm);
fooInspectionArrProm = Promise.settle(fooThenArr);
fooInspectionArrProm = Promise.settle(fooArr);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO expand tests to overloads
fooProm = Promise.any(fooThenArrThen);
fooProm = Promise.any(fooArrProm);
fooProm = Promise.any(fooThenArr);
fooProm = Promise.any(fooArr);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO expand tests to overloads
fooProm = Promise.race(fooThenArrThen);
fooProm = Promise.race(fooArrProm);
fooProm = Promise.race(fooThenArr);
fooProm = Promise.race(fooArr);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//TODO expand tests to overloads
fooArrProm = Promise.some(fooThenArrThen, num);
fooArrProm = Promise.some(fooArrThen, num);
fooArrProm = Promise.some(fooThenArr, num);
fooArrProm = Promise.some(fooArr, num);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooArrProm = Promise.join(foo, foo, foo);
fooArrProm = Promise.join(fooThen, fooThen, fooThen);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// map()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArrThen
barArrProm = Promise.map(fooThenArrThen, (item: Foo) => {
return bar;
});
barArrProm = Promise.map(fooThenArrThen, (item: Foo) => {
return barThen;
});
barArrProm = Promise.map(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = Promise.map(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArrThen
barArrProm = Promise.map(fooArrThen, (item: Foo) => {
return bar;
});
barArrProm = Promise.map(fooArrThen, (item: Foo) => {
return barThen;
});
barArrProm = Promise.map(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = Promise.map(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArr
barArrProm = Promise.map(fooThenArr, (item: Foo) => {
return bar;
});
barArrProm = Promise.map(fooThenArr, (item: Foo) => {
return barThen;
});
barArrProm = Promise.map(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = Promise.map(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArr
barArrProm = Promise.map(fooArr, (item: Foo) => {
return bar;
});
barArrProm = Promise.map(fooArr, (item: Foo) => {
return barThen;
});
barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) => {
return bar;
});
barArrProm = Promise.map(fooArr, (item: Foo, index: number, arrayLength: number) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// reduce()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArrThen
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo) => {
return memo;
}, bar);
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo) => {
return barThen;
}, bar);
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
return memo;
}, bar);
barProm = Promise.reduce(fooThenArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
return barThen;
}, bar);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArrThen
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo) => {
return memo;
}, bar);
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo) => {
return barThen;
}, bar);
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
return memo;
}, bar);
barProm = Promise.reduce(fooArrThen, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
return barThen;
}, bar);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArr
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo) => {
return memo;
}, bar);
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo) => {
return barThen;
}, bar);
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
return memo;
}, bar);
barProm = Promise.reduce(fooThenArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
return barThen;
}, bar);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArr
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo) => {
return memo;
}, bar);
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo) => {
return barThen;
}, bar);
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
return memo;
}, bar);
barProm = Promise.reduce(fooArr, (memo: Bar, item: Foo, index: number, arrayLength: number) => {
return barThen;
}, bar);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// filter()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArrThen
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo) => {
return bool;
});
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo) => {
return boolThen;
});
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
return bool;
});
fooArrProm = Promise.filter(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => {
return boolThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArrThen
fooArrProm = Promise.filter(fooArrThen, (item: Foo) => {
return bool;
});
fooArrProm = Promise.filter(fooArrThen, (item: Foo) => {
return boolThen;
});
fooArrProm = Promise.filter(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
return bool;
});
fooArrProm = Promise.filter(fooArrThen, (item: Foo, index: number, arrayLength: number) => {
return boolThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooThenArr
fooArrProm = Promise.filter(fooThenArr, (item: Foo) => {
return bool;
});
fooArrProm = Promise.filter(fooThenArr, (item: Foo) => {
return boolThen;
});
fooArrProm = Promise.filter(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
return bool;
});
fooArrProm = Promise.filter(fooThenArr, (item: Foo, index: number, arrayLength: number) => {
return boolThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// fooArr
fooArrProm = Promise.filter(fooArr, (item: Foo) => {
return bool;
});
fooArrProm = Promise.filter(fooArr, (item: Foo) => {
return boolThen;
});
fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: number) => {
return bool;
});
fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: number) => {
return boolThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+670
View File
@@ -0,0 +1,670 @@
// Type definitions for bluebird 1.0.0
// Project: https://github.com/petkaantonov/bluebird
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts
// By: Campredon <https://github.com/fdecampredon/>
// Warning: recommended to use `tsc > v0.9.7` (critical bugs in earlier generic code):
// - https://github.com/borisyankov/DefinitelyTyped/issues/1563
// Note: replicate changes to all overloads in both definition and test file
// Note: keep both static and instance members inline (so similar)
// TODO fix remaining TODO annotations in both definition and test
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
declare class Promise<R> implements Promise.Thenable<R> {
/**
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
*/
constructor(callback: (resolve: (thenable: Promise.Thenable<R>) => void, reject: (error: any) => void) => void);
constructor(callback: (resolve: (result: R) => void, reject: (error: any) => void) => void);
/**
* Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
*/
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
/**
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
catch<U>(onReject?: (error: any) => Promise.Thenable<U>): Promise<U>;
caught<U>(onReject?: (error: any) => Promise.Thenable<U>): Promise<U>;
catch<U>(onReject?: (error: any) => U): Promise<U>;
caught<U>(onReject?: (error: any) => U): Promise<U>;
/**
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
*
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise<U>;
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise<U>;
catch<U>(ErrorClass: Function, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
caught<U>(ErrorClass: Function, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
catch<U>(ErrorClass: Function, onReject: (error: any) => U): Promise<U>;
caught<U>(ErrorClass: Function, onReject: (error: any) => U): Promise<U>;
/**
* Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
*/
error<U>(onReject: (reason: any) => Promise.Thenable<U>): Promise<U>;
error<U>(onReject: (reason: any) => U): Promise<U>;
/**
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
*
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
*/
finally(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
finally(handler: (value: R) => R): Promise<R>;
finally(handler: (value: R) => void): Promise<R>;
lastly(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
lastly(handler: (value: R) => R): Promise<R>;
lastly(handler: (value: R) => void): Promise<R>;
/**
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
*/
bind(thisArg: any): Promise<R>;
/**
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
*/
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
/**
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
*/
progressed(handler: (note: any) => any): Promise<R>;
/**
* Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
delay(ms: number): Promise<R>;
/**
* Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
*
* You may specify a custom error message with the `message` parameter.
*/
timeout(ms: number, message?: string): Promise<R>;
/**
* Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
* Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
*/
nodeify(callback: (err: any, value?: R) => void): Promise<R>;
nodeify(...sink: any[]): void;
/**
* Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
*/
cancellable(): Promise<R>;
/**
* Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
*
* That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason.
*
* In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`.
*
* Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable.
*/
// TODO what to do with this?
cancel<U>(): Promise<U>;
/**
* Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
*/
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
fork<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
/**
* Create an uncancellable promise based on this promise.
*/
uncancellable(): Promise<R>;
/**
* See if this promise can be cancelled.
*/
isCancellable(): boolean;
/**
* See if this `promise` has been fulfilled.
*/
isFulfilled(): boolean;
/**
* See if this `promise` has been rejected.
*/
isRejected(): boolean;
/**
* See if this `promise` is still defer.
*/
isPending(): boolean;
/**
* See if this `promise` is resolved -> either fulfilled or rejected.
*/
isResolved(): boolean;
/**
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
*/
inspect(): Promise.Inspection<R>;
/**
* This is a convenience method for doing:
*
* <code>
* promise.then(function(obj){
* return obj[propertyName].call(obj, arg...);
* });
* </code>
*/
call(propertyName: string, ...args: any[]): Promise<any>;
/**
* This is a convenience method for doing:
*
* <code>
* promise.then(function(obj){
* return obj[propertyName];
* });
* </code>
*/
// TODO find way to fix get()
// get<U>(propertyName: string): Promise<U>;
/**
* Convenience method for:
*
* <code>
* .then(function() {
* return value;
* });
* </code>
*
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
*
* Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
*/
return(): Promise<any>;
thenReturn(): Promise<any>;
return<U>(value: U): Promise<U>;
thenReturn<U>(value: U): Promise<U>;
/**
* Convenience method for:
*
* <code>
* .then(function() {
* throw reason;
* });
* </code>
* Same limitations apply as with `.return()`.
*
* Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
*/
throw(reason: Error): Promise<R>;
thenThrow(reason: Error): Promise<R>;
/**
* Convert to String.
*/
toString(): string;
/**
* This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
*/
toJSON(): Object;
/**
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
*/
// TODO how to model instance.spread()? like Q?
spread<U>(onFulfill: Function, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
spread<U>(onFulfill: Function, onReject?: (reason: any) => U): Promise<U>;
/*
// TODO or something like this?
spread<U, W>(onFulfill: (...values: W[]) => Promise.Thenable<U>, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
spread<U, W>(onFulfill: (...values: W[]) => Promise.Thenable<U>, onReject?: (reason: any) => U): Promise<U>;
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise<U>;
*/
/**
* Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
all<U>(): Promise<U[]>;
/**
* Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO how to model instance.props()?
props(): Promise<Object>;
/**
* Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
settle<U>(): Promise<Promise.Inspection<U>[]>;
/**
* Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
any<U>(): Promise<U>;
/**
* Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
some<U>(count: number): Promise<U[]>;
/**
* Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
race<U>(): Promise<U>;
/**
* Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U): Promise<U[]>;
/**
* Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
/**
* Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
filter<U>(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<U[]>;
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise<U[]>;
/**
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
*
* Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.
*
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
*/
static try<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
static try<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
static attempt<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
static attempt<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
/**
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
*/
static method(fn: Function): Function;
/**
* Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
*/
static resolve(): Promise<void>;
static resolve<R>(value: Promise.Thenable<R>): Promise<R>;
static resolve<R>(value: R): Promise<R>;
/**
* Create a promise that is rejected with the given `reason`.
*/
static reject(reason: any): Promise<any>;
static reject<R>(reason: any): Promise<R>;
/**
* Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution).
*/
static defer<R>(): Promise.Resolver<R>;
/**
* Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
*/
static cast<R>(value: Promise.Thenable<R>): Promise<R>;
static cast<R>(value: R): Promise<R>;
/**
* Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`.
*/
static bind(thisArg: any): Promise<void>;
/**
* See if `value` is a trusted Promise.
*/
static is(value: any): boolean;
/**
* Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
*/
static longStackTraces(): void;
/**
* Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise.
*/
// TODO enable more overloads
static delay<R>(value: Promise.Thenable<R>, ms: number): Promise<R>;
static delay<R>(value: R, ms: number): Promise<R>;
static delay(ms: number): Promise<void>;
/**
* Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.
*
* If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
*
* If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
*/
// TODO how to model promisify?
static promisify(nodeFunction: Function, receiver?: any): Function;
/**
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
*
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
*/
// TODO how to model promisifyAll?
static promisifyAll(target: Object): Object;
/**
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
*/
// TODO fix coroutine GeneratorFunction
static coroutine<R>(generatorFunction: Function): Function;
/**
* Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
*/
// TODO fix spawn GeneratorFunction
static spawn<R>(generatorFunction: Function): Promise<R>;
/**
* This is relevant to browser environments with no module loader.
*
* Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else.
*/
static noConflict(): typeof Promise;
/**
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
*
* Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
*/
static onPossiblyUnhandledRejection(handler: (reason: any) => any): void;
/**
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
*/
// TODO enable more overloads
// promise of array with promises of value
static all<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R[]>;
// promise of array with values
static all<R>(values: Promise.Thenable<R[]>): Promise<R[]>;
// array with promises of value
static all<R>(values: Promise.Thenable<R>[]): Promise<R[]>;
// array with values
static all<R>(values: R[]): Promise<R[]>;
/**
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
*
* If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
*
* *The original object is not modified.*
*/
// TODO verify this is correct
// trusted promise for object
static props(object: Promise<Object>): Promise<Object>;
// object
static props(object: Object): Promise<Object>;
/**
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array.
*
* *original: The array is not modified. The input array sparsity is retained in the resulting array.*
*/
// promise of array with promises of value
static settle<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<Promise.Inspection<R>[]>;
// promise of array with values
static settle<R>(values: Promise.Thenable<R[]>): Promise<Promise.Inspection<R>[]>;
// array with promises of value
static settle<R>(values: Promise.Thenable<R>[]): Promise<Promise.Inspection<R>[]>;
// array with values
static settle<R>(values: R[]): Promise<Promise.Inspection<R>[]>;
/**
* Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
*/
// promise of array with promises of value
static any<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
// promise of array with values
static any<R>(values: Promise.Thenable<R[]>): Promise<R>;
// array with promises of value
static any<R>(values: Promise.Thenable<R>[]): Promise<R>;
// array with values
static any<R>(values: R[]): Promise<R>;
/**
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
*
* **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
*/
// promise of array with promises of value
static race<R>(values: Promise.Thenable<Promise.Thenable<R>[]>): Promise<R>;
// promise of array with values
static race<R>(values: Promise.Thenable<R[]>): Promise<R>;
// array with promises of value
static race<R>(values: Promise.Thenable<R>[]): Promise<R>;
// array with values
static race<R>(values: R[]): Promise<R>;
/**
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
*
* If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
*
* *The original array is not modified.*
*/
// promise of array with promises of value
static some<R>(values: Promise.Thenable<Promise.Thenable<R>[]>, count: number): Promise<R[]>;
// promise of array with values
static some<R>(values: Promise.Thenable<R[]>, count: number): Promise<R[]>;
// array with promises of value
static some<R>(values: Promise.Thenable<R>[], count: number): Promise<R[]>;
// array with values
static some<R>(values: R[], count: number): Promise<R[]>;
/**
* Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments.
*/
// variadic array with promises of value
static join<R>(...values: Promise.Thenable<R>[]): Promise<R[]>;
// variadic array with values
static join<R>(...values: R[]): Promise<R[]>;
/**
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
*
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
*
* *The original array is not modified.*
*/
// promise of array with promises of value
static map<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
static map<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
// promise of array with values
static map<R, U>(values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
static map<R, U>(values: Promise.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
// array with promises of value
static map<R, U>(values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
static map<R, U>(values: Promise.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
// array with values
static map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U[]>;
static map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
/**
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
*
* If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
*
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
*/
// promise of array with promises of value
static reduce<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
static reduce<R, U>(values: Promise.Thenable<Promise.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
// promise of array with values
static reduce<R, U>(values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
static reduce<R, U>(values: Promise.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
// array with promises of value
static reduce<R, U>(values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
static reduce<R, U>(values: Promise.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
// array with values
static reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
static reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
/**
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
*
* The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
*
* *The original array is not modified.
*/
// promise of array with promises of value
static filter<R>(values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
static filter<R>(values: Promise.Thenable<Promise.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
// promise of array with values
static filter<R>(values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
static filter<R>(values: Promise.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
// array with promises of value
static filter<R>(values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
static filter<R>(values: Promise.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
// array with values
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<R[]>;
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
}
declare module Promise {
export interface RangeError extends Error {
}
export interface CancellationError extends Error {
}
export interface TimeoutError extends Error {
}
export interface TypeError extends Error {
}
export interface RejectionError extends Error {
}
export interface Thenable<R> {
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
then<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable<U>): Thenable<U>;
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
}
export interface Resolver<R> {
/**
* Returns a reference to the controlled promise that can be passed to clients.
*/
promise: Promise<R>;
/**
* Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state.
*/
resolve(value: R): void;
resolve(): void;
/**
* Reject the underlying promise with `reason` as the rejection reason.
*/
reject(reason: any): void;
/**
* Progress the underlying promise with `value` as the progression value.
*/
progress(value: any): void;
/**
* Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
*
* If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
*/
// TODO specify resolver callback
callback: (err: any, value: R, ...values: R[]) => void;
}
export interface Inspection<R> {
/**
* See if the underlying promise was fulfilled at the creation time of this inspection object.
*/
isFulfilled(): boolean;
/**
* See if the underlying promise was rejected at the creation time of this inspection object.
*/
isRejected(): boolean;
/**
* See if the underlying promise was defer at the creation time of this inspection object.
*/
isPending(): boolean;
/**
* Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object.
*
* throws `TypeError`
*/
value(): R;
/**
* Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object.
*
* throws `TypeError`
*/
error(): any;
}
}
declare module 'bluebird' {
export = Promise;
}
+44 -29
View File
@@ -20,6 +20,7 @@ var exp: RegExp;
var anyArr: any[];
var strArr: string[];
var numArr: number[];
var voidVar: void;
// - - - - - - - - - - - - - - - - -
@@ -199,7 +200,7 @@ bool = fooInspection.isPending();
foo = fooInspection.value();
x = fooInspection.error();
x = fooInspection.reason();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -244,9 +245,15 @@ barProm = fooProm.caught((reason: any) => {
barProm = fooProm.catch(Error, (reason: any) => {
return bar;
});
barProm = fooProm.catch(Promise.CancellationError, (reason: any) => {
return bar;
});
barProm = fooProm.caught(Error, (reason: any) => {
return bar;
});
barProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -256,36 +263,28 @@ barProm = fooProm.error((reason: any) => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.finally((value: Foo) => {
// return is ignored
return foo;
});
fooProm = fooProm.finally((value: Foo) => {
// return is ignored
return fooThen;
});
fooProm = fooProm.finally((value: Foo) => {
// return is ignored
fooProm = fooProm.finally(() => {
// non-Thenable return is ignored
return "foo";
});
fooProm = fooProm.finally(() => {
// return is ignored
return fooThen;
});
fooProm = fooProm.finally(() => {
// non-Thenable return is ignored
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.lastly((value: Foo) => {
// return is ignored
return foo;
});
fooProm = fooProm.lastly((value: Foo) => {
// return is ignored
return fooThen;
});
fooProm = fooProm.lastly((value: Foo) => {
// return is ignored
fooProm = fooProm.lastly(() => {
// non-Thenable return is ignored
return "foo";
});
fooProm = fooProm.lastly(() => {
// return is ignored
return fooThen;
});
fooProm = fooProm.lastly(() => {
// non-Thenable return is ignored
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -294,40 +293,56 @@ fooProm = fooProm.bind(obj);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.done((value: Foo) => {
voidVar = fooProm.done((value: Foo) => {
return bar;
}, (reason: any) => {
return bar;
}, (note: any) => {
});
barProm = fooProm.done((value: Foo) => {
voidVar = fooProm.done((value: Foo) => {
return bar;
}, (reason: any) => {
return bar;
});
barProm = fooProm.done((value: Foo) => {
voidVar = fooProm.done((value: Foo) => {
return bar;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.done((value: Foo) => {
voidVar = fooProm.done((value: Foo) => {
return barThen;
}, (reason: any) => {
return barThen;
}, (note: any) => {
});
barProm = fooProm.done((value: Foo) => {
voidVar = fooProm.done((value: Foo) => {
return barThen;
}, (reason: any) => {
return barThen;
});
barProm = fooProm.done((value: Foo) => {
voidVar = fooProm.done((value: Foo) => {
return barThen;
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.tap((value: Foo) => {
// non-Thenable return is ignored
return "foo";
});
fooProm = fooProm.tap((value: Foo) => {
return fooThen;
});
fooProm = fooProm.tap((value: Foo) => {
return voidThen;
});
fooProm = fooProm.tap(() => {
// non-Thenable return is ignored
});
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
fooProm = fooProm.progressed((note: any) => {
+52 -12
View File
@@ -16,7 +16,7 @@
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
declare class Promise<R> implements Promise.Thenable<R> {
declare class Promise<R> implements Promise.Thenable<R>, Promise.Inspection<R> {
/**
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
*/
@@ -72,13 +72,11 @@ declare class Promise<R> implements Promise.Thenable<R> {
*
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
*/
finally(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
finally(handler: (value: R) => R): Promise<R>;
finally(handler: (value: R) => void): Promise<R>;
finally<U>(handler: () => Promise.Thenable<U>): Promise<R>;
finally<U>(handler: () => U): Promise<R>;
lastly(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
lastly(handler: (value: R) => R): Promise<R>;
lastly(handler: (value: R) => void): Promise<R>;
lastly<U>(handler: () => Promise.Thenable<U>): Promise<R>;
lastly<U>(handler: () => U): Promise<R>;
/**
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
@@ -88,10 +86,16 @@ declare class Promise<R> implements Promise.Thenable<R> {
/**
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
*/
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): void;
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): void;
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): void;
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): void;
/**
* Like `.finally()`, but not called for rejections.
*/
tap<U>(onFulFill: (value: R) => Promise.Thenable<U>): Promise<R>;
tap<U>(onFulfill: (value: R) => U): Promise<R>;
/**
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
@@ -172,6 +176,20 @@ declare class Promise<R> implements Promise.Thenable<R> {
*/
isResolved(): boolean;
/**
* Get the fulfillment value of the underlying promise. Throws if the promise isn't fulfilled yet.
*
* throws `TypeError`
*/
value(): R;
/**
* Get the rejection reason for the underlying promise. Throws if the promise isn't rejected yet.
*
* throws `TypeError`
*/
reason(): any;
/**
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
*/
@@ -594,6 +612,20 @@ declare module Promise {
}
export interface RejectionError extends Error {
}
export interface OperationalError extends Error {
}
// Ideally, we'd define e.g. "export class RangeError extends Error {}",
// but as Error is defined as an interface (not a class), TypeScript doesn't
// allow extending Error, only implementing it.
// However, if we want to catch() only a specific error type, we need to pass
// a constructor function to it. So, as a workaround, we define them here as such.
export function RangeError(): RangeError;
export function CancellationError(): CancellationError;
export function TimeoutError(): TimeoutError;
export function TypeError(): TypeError;
export function RejectionError(): RejectionError;
export function OperationalError(): OperationalError;
export interface Thenable<R> {
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
@@ -661,8 +693,16 @@ declare module Promise {
*
* throws `TypeError`
*/
error(): any;
reason(): any;
}
/**
* Changes how bluebird schedules calls a-synchronously.
*
* @param scheduler Should be a function that asynchronously schedules
* the calling of the passed in function
*/
export function setScheduler(scheduler: (callback: (...args: any[]) => void) => void): void;
}
declare module 'bluebird' {
+1
View File
@@ -376,6 +376,7 @@ declare module breeze {
clear(): void;
createEmptyCopy(): EntityManager;
createEntity(typeName: string, config?: {}, entityState?: EntityStateSymbol) : Entity;
createEntity(typeName: string, config?: {}, entityState?: EntityStateSymbol, mergeStrategy?: StrategySymbol): Entity;
createEntity(entityType: EntityType, config?: {}, entityState?: EntityStateSymbol): Entity;
detachEntity(entity: Entity): boolean;
executeQuery(query: string, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): Q.Promise<QueryResult>;
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for buffer-equal 1.0 0
// Type definitions for buffer-equal 0.0.1
// Project: https://github.com/substack/node-buffer-equal
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -0,0 +1,14 @@
/// <reference path="./bunyan-logentries.d.ts" />
/// <reference path="../bunyan/bunyan.d.ts" />
import bunyan = require("bunyan");
import bunyanLogentries = require("bunyan-logentries");
var logger: bunyan.Logger = bunyan.createLogger({
name: "foobar",
streams: [{
level: "info",
stream: bunyanLogentries.createStream({token: "foobar"}),
type: "raw"
}]
});
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for node-bunyan-logentries v0.1.0
// Project: https://github.com/nemtsov/node-bunyan-logentries
// Definitions by: Aymeric Beaumet <http://aymericbeaumet.me>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../bunyan/bunyan.d.ts" />
declare module "bunyan-logentries" {
import bunyan = require("bunyan");
interface StreamOptions {
token: string;
}
export function createStream(options: StreamOptions): NodeJS.WritableStream;
}
+1 -1
View File
@@ -96,7 +96,7 @@ log.fatal(error);
log.fatal(object);
log.fatal('Hello, %s', 'world!');
var recursive = {
var recursive: any = {
hello: 'world',
whats: {
huh: recursive
+1
View File
@@ -15,6 +15,7 @@ declare module "bunyan" {
addStream(stream:Stream):void;
addSerializers(serializers:Serializers):void;
child(options:LoggerOptions, simple?:boolean):Logger;
child(obj:Object, simple?:boolean):Logger;
reopenFileStreams():void;
level(value:any /* number | string */):void;
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for business-rules-engine - v1.0.20
// Type definitions for business-rules-engine v1.0.20
// Project: https://github.com/rsamec/form
// Definitions by: Roman Samec <https://github.com/rsamec>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for CanvasJS v1.5.1 GA
// Type definitions for CanvasJS v1.5.1
// Project: http://canvasjs.com/
// Definitions by: Mark Overholt <https://github.com/mover5>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for CasperJS v1.0.0 API
// Type definitions for CasperJS v1.0.0
// Project: http://casperjs.org/
// Definitions by: Jed Mao <https://github.com/jedmao>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for chai-fuzzy 1.3.0 assert style
// Type definitions for chai-fuzzy 1.3.0
// Project: http://chaijs.com/plugins/chai-fuzzy
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+1
View File
@@ -94,6 +94,7 @@ declare module chai {
that: Expect;
and: Expect;
have: Expect;
has: Expect;
with: Expect;
at: Expect;
of: Expect;
+37
View File
@@ -0,0 +1,37 @@
/// <reference path="change-case.d.ts"/>
import changeCase = require("change-case");
var s: string;
var b: boolean;
s = changeCase.dot(s);
s = changeCase.dotCase(s);
s = changeCase.swap(s);
s = changeCase.swapCase(s);
s = changeCase.path(s);
s = changeCase.pathCase(s);
s = changeCase.upper(s);
s = changeCase.upperCase(s);
s = changeCase.lower(s);
s = changeCase.lowerCase(s);
s = changeCase.camel(s);
s = changeCase.camelCase(s);
s = changeCase.snake(s);
s = changeCase.snakeCase(s);
s = changeCase.title(s);
s = changeCase.titleCase(s);
s = changeCase.param(s);
s = changeCase.paramCase(s);
s = changeCase.pascal(s);
s = changeCase.pascalCase(s);
s = changeCase.constant(s);
s = changeCase.constantCase(s);
s = changeCase.sentence(s);
s = changeCase.sentenceCase(s);
b = changeCase.isUpper(s);
b = changeCase.isUpperCase(s);
b = changeCase.isLower(s);
b = changeCase.isLowerCase(s);
s = changeCase.ucFirst(s);
s = changeCase.upperCaseFirst(s);
+37
View File
@@ -0,0 +1,37 @@
// Type definitions for change-case
// Project: https://github.com/blakeembrey/change-case
// Definitions by: Asana <https://asana.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "change-case" {
function dot(s: string): string;
function dotCase(s: string): string;
function swap(s: string): string;
function swapCase(s: string): string;
function path(s: string): string;
function pathCase(s: string): string;
function upper(s: string): string;
function upperCase(s: string): string;
function lower(s: string): string;
function lowerCase(s: string): string;
function camel(s: string): string;
function camelCase(s: string): string;
function snake(s: string): string;
function snakeCase(s: string): string;
function title(s: string): string;
function titleCase(s: string): string;
function param(s: string): string;
function paramCase(s: string): string;
function pascal(s: string): string;
function pascalCase(s: string): string;
function constant(s: string): string;
function constantCase(s: string): string;
function sentence(s: string): string;
function sentenceCase(s: string): string;
function isUpper(s: string): boolean;
function isUpperCase(s: string): boolean;
function isLower(s: string): boolean;
function isLowerCase(s: string): boolean;
function ucFirst(s: string): string;
function upperCaseFirst(s: string): string;
}
+14
View File
@@ -0,0 +1,14 @@
/// <reference path="checksum.d.ts" />
import checksum = require("checksum");
var s: string = checksum("abcd");
var t: string = checksum("abcd", { algorithm: 'sha1' });
checksum.file("myfile.txt", (error: Error, hash: string): void => {
// do nothing
});
checksum.file("myfile.txt", { algorithm: 'sha1' }, (error: Error, hash: string): void => {
// do nothing
});
+44
View File
@@ -0,0 +1,44 @@
// Type definitions for checksum 0.1.1
// Project: https://github.com/dshaw/checksum
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "checksum" {
module checksum {
/**
* Options object for all functions
*/
interface ChecksumOptions {
/**
* Algorithm to use, default 'sha1'
* Can be 'sha1' or 'md5' (see module 'crypto').
*/
algorithm?: string;
}
/**
* Generate the checksum for a file on disk
* @param filename The file name
* @param callback Callback which is called with the result or an error
*/
function file(filename: string, callback: (error: Error, hash: string) => void): void;
/**
* Generate the checksum for a file on disk
* @param filename The file name
* @param options Options object to indicate hash algo
* @param callback Callback which is called with the result or an error
*/
function file(filename: string, options: ChecksumOptions, callback: (error: Error, hash: string) => void): void;
}
/**
* Generates a checksum for the given value
* @param value Any value
* @param options Allows to set the algorithm
* @returns Checksum
*/
function checksum(value: any, options?: checksum.ChecksumOptions): string;
export = checksum;
}
+50 -1
View File
@@ -251,4 +251,53 @@ function test_dom_window() {
var size = win.getViewPaneSize();
alert(size.width);
alert(size.height);
}
}
function test_adding_dialog_by_path() {
CKEDITOR.dialog.add( 'abbrDialog', this.path + 'dialogs/abbr.js' );
}
function test_adding_dialog_by_definition() {
CKEDITOR.dialog.add( 'abbrDialog', function ( editor: CKEDITOR.editor ) {
return {
title: 'Abbreviation Properties',
minWidth: 400,
minHeight: 200,
contents: [
{
id: 'tab-basic',
label: 'Basic Settings',
elements: <any[]>[]
},
{
id: 'tab-adv',
label: 'Advanced Settings',
elements: []
}
]
};
});
}
function test_adding_plugin() {
CKEDITOR.plugins.add( 'abbr', {
icons: 'abbr',
init: function( editor: CKEDITOR.editor ) {
// empty logic
}
});
}
function test_adding_widget() {
function wrapper(editor: CKEDITOR.editor) {
editor.widgets.add("widgetty", {
button: "Activate widgetty",
template: "<imaginary-element>",
dialog: "widgetty",
init: function() {
// no logic
}
});
}
}
+161 -1
View File
@@ -550,11 +550,17 @@ declare module CKEDITOR {
}
interface toolbarGroups {
name?: string;
groups?: string[];
}
interface config {
startupMode?: string;
removeButtons?: string;
removePlugins?: string;
toolbar?: any;
toolbarGroups?: toolbarGroups[];
skin?: string;
language?: string;
plugins?: string;
@@ -614,11 +620,134 @@ declare module CKEDITOR {
module widget {
class repository {
interface IWidget {
allowedContent: any;
button: string;
contentForms: Object;
contentTransformations: Object;
data: Function;
defaults: Object;
dialog: String;
downcast: any; // should be string | Function
downcasts: Object;
draggable: boolean;
editables: Object;
init: Function;
inline: Boolean;
insert: Function;
mask: Boolean;
name: String;
parts: Object;
pathName: string;
requiredContent: any;
styleToAllowedContentRules: Function;
styleableElements: string;
template: string;
upcast: any; // should be string | Function
upcasts: Object;
addClass(className: string): void;
applyStyle(style: any): void; // any should be CKEDITOR.style
capture(): void;
checkStyleActive(style: any): boolean; // any should be CKEDITOR.style
define(name: string, meta: {errorProof?: boolean}): void;
destroy(offline?: boolean): void;
destroyEditable(editableName:string, offline?: boolean): void;
edit(): boolean;
fire(eventName: string, data?: Object, editor?: editor): any; // should be boolean | Object
fireOnce(eventName: string, data?: Object, editor?: editor): any; // should be boolean | Object
focus(): void;
getClasses(): Object;
hasClass(className: string, Whether: boolean): void;
hasListeners(eventName: string): boolean;
initEditable(editableName: string, definition: any): boolean; // any should be CKEDITOR.plugins.widget.nestedEditable.definition
isInited(): boolean;
isReady(): boolean;
on(eventName: string, listenerFunction: Function,
scopeObj: Object, listenerData: Object, priority: number): Object;
once(): void;
removeAllListeners(): void;
removeClass(className: string): void;
removeListener(evnetName: string, listenerFunction: Function): void;
removeStyle(style: any): void; // any should be CKEDITOR.style
setData(keyOrData: any, value?: Object): IWidget; // any should be string | Object
setFocused(selected: boolean): IWidget;
setSelected(selected: boolean): IWidget;
toFeature(): any; // should be CKEDITOR.feature
updateDragHandlerPosition(): void;
}
interface IWidgetDefinition {
allowedContent?: any;
button?: string;
contentForms?: Object;
contentTransformations?: Object;
data?: Function;
defaults?: Object;
dialog?: String;
downcast?: any; // should be string | Function
downcasts?: Object;
draggable?: boolean;
edit?: Function;
editables?: Object;
init?: Function;
inline?: Boolean;
insert?: Function;
mask?: Boolean;
name?: String;
parts?: Object;
pathName?: string;
requiredContent?: any;
styleToAllowedContentRules?: Function;
styleableElements?: string;
template?: string;
upcast?: any; // should be string | Function
upcasts?: Object;
toFeature?(): any; // should be CKEDITOR.feature
}
class repository {
add(name: string, widgetDef: IWidgetDefinition): void;
addUpcastCallback(callback: Function): void;
capture(): void;
checkSelection(): void;
checkWidgets(options?: {initOnlyNew?: boolean; focusInited?: boolean}): void;
define(name: string, meta?: {errorProof?: boolean}): void;
del(widget: IWidget): void;
destroy(widget: IWidget, offline?: boolean): void;
destroyAll(offline?: boolean): void;
finalizeCreation(container: any): void;
fire(eventName: string, data: Object, editor: editor): any; // should be boolean | Object
getByElement(element: any, checkWrapperOnly: boolean): IWidget;
hasListeners(eventName: string): boolean;
initOn(element: any, widgetDef?: IWidgetDefinition, startupData?: Object): IWidget;
initOnAll(container?: any): IWidget[];
on(eventName: string, listenerFunction: Function, scopeObj?: Object, listenerData?: Object, priority?: number): Object;
once(): void;
parseElementClasses(classes: string): Object;
removeAllListeners(eventName: string, listenerFunction: Function): void;
wrapElement(element: any, widgetName?: string): any;
}
}
interface IPluginDefinition {
hidpi?: boolean;
lang?: any; // should be string | string[]
requires?: any; // should be string | string[]a
afterInit?(editor: editor): any;
beforeInit?(editor: editor): any;
init?(editor: editor): any;
onLoad?(): any;
}
function add(name: string, definition?: IPluginDefinition): void;
function addExternal(name: string, path: string, fileName: string): void;
function get(name: string): any;
function getFilePath(name: string): string;
function getPath(name: string): string;
function load(name: string, callback: string, scope: any): void;
function setLang(pluginName: string, languageCode: string, languageEntries: any): void;
}
@@ -963,4 +1092,35 @@ declare module CKEDITOR {
addFocusable(element: CKEDITOR.dom.element, index: number): void;
}
module tools {
var callFunction: Function;
}
module dialog {
interface IDialogDefinition {
buttons?: any[];
contents?: any[];
height?: number;
minHeight?: number;
minWidth?: number;
onCancel?: Function;
onLoad?: Function;
onOk?: Function;
onShow?: Function;
resizable?: number;
title?: string;
width?: number;
}
function add(name: string, path: string): void;
function add(name: string, dialogDefinition: IDialogDefinition): void;
function addIframe(name: string, title: string, minWidth: number,
minHeight: number, onContentLoad: Function, userDefinition: any): void;
function addUIElement(typeName: string, builder: Function): void;
function cancelButton(): void;
function exists(name: string): void;
function getCurrent(): void;
function isTabEnabled(editor: editor, dialogName: string, tabName: string): boolean;
function okButton(): void;
}
}
+47
View File
@@ -0,0 +1,47 @@
/// <reference path="content-type.d.ts" />
import MediaType = require('content-type');
// https://github.com/deoxxa/content-type/blob/master/README.md
function new_test(): void {
var p = new MediaType('text/html;level=1;q=0.5');
p.q === 0.5;
p.params.level === "1";
var q = new MediaType('application/json', { profile: 'http://example.com/schema.json' });
q.type === "application/json";
q.params.profile === "http://example.com/schema.json";
q.q = 1;
q.toString() === 'application/json;q=1;profile="http://example.com/schema.json"';
}
function mediaCmp_test(): void {
MediaType.mediaCmp(MediaType.parseMedia('text/html'), MediaType.parseMedia('text/html')) === 0;
MediaType.mediaCmp(MediaType.parseMedia('*/*'), MediaType.parseMedia('text/html')) === 1;
MediaType.mediaCmp(MediaType.parseMedia('text/html;level=1'), MediaType.parseMedia('text/html')) === -1;
MediaType.mediaCmp(MediaType.parseMedia('application/json;profile="v1.json"'), MediaType.parseMedia('application/json;profile="v2.json"')) === null;
}
// https://github.com/deoxxa/content-type/blob/master/example.js
function example(): void {
var representations = [
'application/json',
'text/html',
'application/json;profile="schema.json"',
'application/json;profile="different.json"',
];
var accept = [
'text/html;q=0.50',
'*/*;q=0.01',
'application/json;profile=different.json',
'application/json;profile="a,b;c.json?d=1;f=2";q=0.2',
];
console.log('Formats:\n\t' + representations.map(MediaType.parseMedia).join('\n\t'));
console.log('Accept:\n\t' + accept.map(MediaType.parseMedia).join('\n\t'));
console.log('Selected:', (MediaType.select(representations.map(MediaType.parseMedia), accept.map(MediaType.parseMedia)) || 'None').toString());
}
+32
View File
@@ -0,0 +1,32 @@
// Type definitions for content-type v0.0.1
// Project: https://github.com/deoxxa/content-type
// Definitions by: Pine Mizune <https://github.com/pine613>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module ContentType {
interface MediaType {
type: string;
q?: number;
params: any;
toString(): string;
}
interface SelectOptions {
sortAvailable?: boolean;
sortAccepted?: boolean;
}
interface MediaTypeStatic {
new (s: string, p?: any): MediaType;
parseMedia(type: string): MediaType;
splitQuotedString(str: string, delimiter?: string, quote?: string): string[];
splitContentTypes(str: string): string[];
select(availableTypes: MediaType[], acceptedTypes: MediaType[], options?: SelectOptions): string;
mediaCmp(a: MediaType, b: MediaType): number;
}
}
declare module "content-type" {
var x: ContentType.MediaTypeStatic;
export = x;
}
+33
View File
@@ -0,0 +1,33 @@
/// <reference path="cookie.d.ts" />
import cookie = require('cookie');
function test_serialize(): void {
var retVal: string;
retVal = cookie.serialize('foo', 'bar');
retVal = cookie.serialize('foo', 'bar', { httpOnly: true });
}
function test_parse(): void {
var retVal: { [key: string]: string };
retVal = cookie.parse('foo=bar; bar=baz;');
retVal = cookie.parse('foo=bar; bar=baz', { decode: x => x });
}
function test_options(): void {
var serializeOptions: CookieSerializeOptions = {
encode: (x: string) => x,
path: '/',
expires: new Date(),
maxAge: 200,
domain: 'example.com',
secure: false,
httpOnly: false
};
var parseOptios: CookieParseOptions = {
decode: (x: string) => x
};
}
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for cookie v0.1.2
// Project: https://github.com/jshttp/cookie
// Definitions by: Pine Mizune <https://github.com/pine613>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface CookieSerializeOptions {
encode?: (val: string) => string;
path?: string;
expires?: Date;
maxAge?: number;
domain?: string;
secure?: boolean;
httpOnly?: boolean;
}
interface CookieParseOptions {
decode?: (val: string) => string;
}
interface CookieStatic {
serialize(name: string, val: string, options?: CookieSerializeOptions): string;
parse(str: string, options?: CookieParseOptions): { [key: string]: string };
}
declare module "cookie" {
var cookie: CookieStatic;
export = cookie;
}
+30
View File
@@ -0,0 +1,30 @@
/// <reference path="cookiejs.d.ts" />
// Based on https://github.com/js-coder/cookie.js/blob/gh-pages/tests/spec.js
cookie.set({a: '1', b: '2', c: '3'});
cookie;
cookie.enabled();
cookie.set('n', '5');
cookie.get('a');
cookie.get('__undef__');
cookie.get('__undef__', 'fallback');
cookie.get(['a', 'b']);
cookie.get(['a', '__undef__'], 'fallback');
cookie('a');
cookie('__undef__');
cookie('__undef__', 'fallback');
cookie(['a', 'b']);
cookie(['a', '__undef__'], 'fallback');
cookie.remove('a');
cookie.remove('a', 'b');
cookie.remove(['a', 'b']);
cookie.empty();
cookie.all();
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for cookie.js v1.0.0
// Project: https://github.com/js-coder/cookie.js
// Definitions by: Boltmade <https://github.com/Boltmade>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare function cookie(key : string, fallback?: string) : string;
declare function cookie(keys : string[], fallback?: string) : string;
declare module cookie {
export function set(key : string, value : string, options? : any) : void;
export function set(obj : any, options? : any) : void;
export function remove(key : string) : void;
export function remove(keys : string[]) : void;
export function remove(...args : string[]) : void;
export function empty() : void;
export function get(key : string, fallback?: string) : string;
export function get(keys : string[], fallback?: string) : string;
export function all() : any;
export function enabled() : boolean;
}
declare module "cookiejs" {
export = cookie;
}
+10 -8
View File
@@ -7,14 +7,16 @@
// Licensed under the MIT license.
interface Window {
plugins: {
/**
* This plugin allows to receive push notifications. The Android implementation uses
* Google's GCM (Google Cloud Messaging) service,
* whereas the iOS version is based on Apple APNS Notifications
*/
pushNotification: PushNotification
}
plugins: Plugins
}
interface Plugins {
/**
* This plugin allows to receive push notifications. The Android implementation uses
* Google's GCM (Google Cloud Messaging) service,
* whereas the iOS version is based on Apple APNS Notifications
*/
pushNotification: PushNotification
}
/**
Vendored
+9 -2
View File
@@ -89,7 +89,7 @@ declare module D3 {
* @param arr Array to search
* @param map Accsessor function
*/
min<T, U>(arr: T[], map: (v: T) => U): U;
min<T, U>(arr: T[], map: (v?: T, i?: number) => U): U;
/**
* Find the minimum value in an array
*
@@ -102,7 +102,7 @@ declare module D3 {
* @param arr Array to search
* @param map Accsessor function
*/
max<T, U>(arr: T[], map: (v: T) => U): U;
max<T, U>(arr: T[], map: (v?: T, i?: number) => U): U;
/**
* Find the maximum value in an array
*
@@ -233,6 +233,13 @@ declare module D3 {
*/
transpose(matrix: any[]): any[];
/**
* Creates an array containing tuples of adjacent pairs
*
* @param arr An array containing entries to pair
* @returns any[][] An array of 2-element tuples for each pair
*/
pairs(arr: any[]): any[][];
/**
* List the keys of an associative array.
*
* @param map Array of objects to get the key values from
+159
View File
@@ -0,0 +1,159 @@
/////////////////////////////////////////////////////////////
// http://workshop.chromeexperiments.com/examples/gui/
//////////////////////////////////////////////////////////////
/// <reference path="dat-gui.d.ts" />
// ------------ config
var FizzyText = function () {
return {
message: 'dat.gui',
speed: 0.8,
displayOutline: false,
explode: function () {},
noiseStrength: 0.5
// Define render logic ...
}
};
// ------------ 1. Basic Usage
() => {
window.onload = function () {
var text = FizzyText();
var gui = new dat.GUI();
gui.add(text, 'message');
gui.add(text, 'speed', -5, 5);
gui.add(text, 'displayOutline');
gui.add(text, 'explode');
};
}
// ------------ 2. Constraining Input
() => {
var text = FizzyText();
var gui = new dat.GUI();
gui.add(text, 'noiseStrength').step(5); // Increment amount
gui.add(text, 'growthSpeed', -5, 5); // Min and max
gui.add(text, 'maxSize').min(0).step(0.25); // Mix and match
// Choose from accepted values
gui.add(text, 'message', ['pizza', 'chrome', 'hooray']);
// Choose from named values
gui.add(text, 'speed', {Stopped: 0, Slow: 0.1, Fast: 5});
}
// ------------ 3. Folders
() => {
var text = FizzyText();
var gui = new dat.GUI();
var f1 = gui.addFolder('Flow Field');
f1.add(text, 'speed');
f1.add(text, 'noiseStrength');
var f2 = gui.addFolder('Letters');
f2.add(text, 'growthSpeed');
f2.add(text, 'maxSize');
f2.add(text, 'message');
f2.open();
}
// ------------ 4. Color Controllers
() => {
var FizzyText = function () {
return {
color0: "#ffae23", // CSS string
color1: [0, 128, 255], // RGB array
color2: [0, 128, 255, 0.3], // RGB with alpha
color3: {h: 350, s: 0.9, v: 0.3} // Hue, saturation, value
// Define render logic ...
}
};
window.onload = function () {
var text = FizzyText();
var gui = new dat.GUI();
gui.addColor(text, 'color0');
gui.addColor(text, 'color1');
gui.addColor(text, 'color2');
gui.addColor(text, 'color3');
};
}
// ------------ 5. Saving Values
() => {
var fizzyText = FizzyText();
var gui = new dat.GUI();
gui.remember(fizzyText);
}
// ------------ 6. Presets
() => {
var gui = new dat.GUI({
load: JSON,
preset: 'Flow'
});
}
// ------------ 7. Events
() => {
var fizzyText = FizzyText();
var gui = new dat.GUI();
var controller = gui.add(fizzyText, 'maxSize', 0, 10);
controller.onChange(function (value) {
// Fires on every change, drag, keypress, etc.
});
controller.onFinishChange(function (value) {
// Fires when a controller loses focus.
alert("The new value is " + value);
});
}
// ------------ 8. Custom Placement
() => {
var gui = new dat.GUI({autoPlace: false});
var customContainer = document.getElementById('my-gui-container');
customContainer.appendChild(gui.domElement);
}
// ------------ 9. Updating the Display Automatically
() => {
var fizzyText = FizzyText();
var gui = new dat.GUI();
gui.add(fizzyText, 'noiseStrength', 0, 100).listen();
var update = function () {
requestAnimationFrame(update);
fizzyText.noiseStrength = Math.random();
};
update();
}
// ------------ 10. Updating the Display Manually
() => {
var fizzyText = FizzyText();
var gui = new dat.GUI();
gui.add(fizzyText, 'noiseStrength', 0, 100);
var update = function () {
var dt = new Date();
requestAnimationFrame(update);
fizzyText.noiseStrength = Math.cos(dt.getTime());
// Iterate over all controllers
for (var i in gui.__controllers) {
gui.__controllers[i].updateDisplay();
}
};
update();
}
+57
View File
@@ -0,0 +1,57 @@
// Type definitions for dat.GUI v0.5
// Project: https://github.com/dataarts/dat.gui
// Definitions by: Satoru Kimura <https://github.com/gyohk>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module dat {
export class GUI {
constructor(option?: GUIParams);
__controllers: GUIController[];
__folders: GUI[];
domElement: HTMLElement;
add(target: Object, propName:string): GUIController;
add(target: Object, propName:string, min: number, max: number): GUIController;
add(target: Object, propName:string, status: boolean): GUIController;
add(target: Object, propName:string, items:string[]): GUIController;
add(target: Object, propName:string, items:number[]): GUIController;
add(target: Object, propName:string, items:Object): GUIController;
addColor(target: Object, propName:string): GUIController;
addColor(target: Object, propName:string, color: string): GUIController;
addColor(target: Object, propName:string, rgba: number[]): GUIController; // rgb or rgba
addColor(target: Object, propName:string, hsv:{h:number; s:number; v:number}): GUIController;
addFolder(propName:string): GUI;
close(): void;
open(): void;
remember(target: Object): void;
}
export interface GUIParams{
autoPlace?: boolean;
closed?: boolean;
load?: any;
name?: string;
preset?: string;
width?: number;
}
export class GUIController {
destroy(): void;
fire(): GUIController;
getValue(): any;
isModified(): boolean;
listen(): GUIController;
min(n: number): GUIController;
remove(target: GUIController): void;
setValue(value: any): GUIController;
step(n: number): GUIController;
updateDisplay(): void;
onChange: (value?: any) => void;
onFinishChange: (value?: any) => void;
}
}
+20
View File
@@ -0,0 +1,20 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="debug.d.ts" />
import debug = require("debug");
debug.disable();
debug.enable("DefinitelyTyped:*");
var log: debug.Debugger = debug("DefinitelyTyped:log");
log("Just text");
log("Formatted test (%d arg)", 1);
log("Formatted %s (%d args)", "test", 2);
log("Enabled?: %s", debug.enabled("DefinitelyTyped:log"));
log("Namespace: %s", log.namespace);
var error: debug.Debugger = debug("DefinitelyTyped:error");
error.log = console.error.bind(console);
error("This should be printed to stderr");
+30
View File
@@ -0,0 +1,30 @@
// Type definitions for debug
// Project: https://github.com/visionmedia/debug
// Definitions by: Seon-Wook Park <https://github.com/swook>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "debug" {
function d(namespace: string): d.Debugger;
module d {
export var log: Function;
function enable(namespaces: string): void;
function disable(): void;
function enabled(namespace: string): boolean;
export interface Debugger {
(formatter: any, ...args: any[]): void;
enabled: boolean;
log: Function;
namespace: string;
}
}
export = d;
}
+32 -27
View File
@@ -4,8 +4,9 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path="../jquery/jquery.d.ts" />
declare module DevExpress {
export function abstract(): void;
declare module DevExpress {
export function abstract(): void;
export var rtlEnabled: boolean;
export var hardwareBackButton: JQueryCallback;
interface Endpoint {
@@ -83,8 +84,8 @@ export function abstract(): void;
}): void;
}
}
declare module DevExpress.data {
export interface DataError extends Error {
declare module DevExpress.data {
export interface DataError extends Error {
httpStatus?: number;
errorDetails?: any;
}
@@ -204,7 +205,7 @@ export interface DataError extends Error {
export module queryAdapters {
export function odata(queryOptions: ODataQueryOptions): RemoteQuery;
}
export interface DataSourceOptions {
export interface DataSourceOptions {
map? (item: any): any;
postProcess? (result: any[]): any;
pageSize: number;
@@ -244,7 +245,7 @@ export interface DataSourceOptions {
load(): JQueryPromise<any>;
dispose(): void;
}
export interface StoreOptions {
export interface StoreOptions {
key?: any;
errorHandler?: ErrorHandler;
loaded?: (result: Array<any>) => void;
@@ -350,7 +351,11 @@ export interface StoreOptions {
objectLink(entityAlias: string, key: any): { __metadata: { uri: string }; };
}
}
declare module DevExpress.ui {
declare module DevExpress.ui {
export var themes: {
current(): string;
current(themeName: string): void;
};
interface ViewportOptions {
allowPan?: boolean;
allowZoom?: boolean;
@@ -406,7 +411,7 @@ declare module DevExpress.ui {
export function confirm(options: DialogOptions): JQueryPromise<boolean>;
export function confirm(message: string, title?: string): JQueryPromise<boolean>;
}
export interface CollectionContainerWidgetOptions extends WidgetOptions {
export interface CollectionContainerWidgetOptions extends WidgetOptions {
items?: Array<any>;
itemTemplate?: any;
itemRender?: Function;
@@ -423,7 +428,7 @@ export interface CollectionContainerWidgetOptions extends WidgetOptions {
constructor(element: Element, options?: CollectionContainerWidgetOptions);
constructor(element: JQuery, options?: CollectionContainerWidgetOptions);
}
export interface WidgetOptions extends ComponentOptions {
export interface WidgetOptions extends ComponentOptions {
contentReadyAction?: any;
width?: any;
height?: any;
@@ -437,7 +442,7 @@ export interface WidgetOptions extends ComponentOptions {
repaint(): void;
addTemplate(template: ITemplate): void;
}
export interface dxEditorOptions extends WidgetOptions {
export interface dxEditorOptions extends WidgetOptions {
value?: any;
valueChangeAction?: any;
}
@@ -446,8 +451,8 @@ export interface dxEditorOptions extends WidgetOptions {
constructor(element: JQuery, options?: dxEditorOptions);
}
}
declare module DevExpress.viz {
export class Chart extends Component {
declare module DevExpress.viz {
export class Chart extends Component {
constructor(element: Element, options?: viz.charts.ChartOptions);
constructor(element: JQuery, options?: viz.charts.ChartOptions);
clearSelection(): void;
@@ -563,8 +568,8 @@ export class Chart extends Component {
convertCoordinates(x: number, y: number): Array<number>;
}
}
declare module DevExpress.viz.charts {
interface z_BaseLegendOptions {
declare module DevExpress.viz.charts {
interface z_BaseLegendOptions {
backgroundColor?: string;
hoverMode?: string;
customizeText?: (arg: {
@@ -930,8 +935,8 @@ interface z_BaseLegendOptions {
asyncSeriesRendering?: boolean;
}
}
declare module DevExpress.viz.charts.series {
export interface z_BasePointStyle {
declare module DevExpress.viz.charts.series {
export interface z_BasePointStyle {
color?: string;
border?: {
visible?: boolean;
@@ -1249,8 +1254,8 @@ export interface z_BasePointStyle {
isHovered(): boolean;
}
}
declare module DevExpress.viz.common {
export interface FontOptions {
declare module DevExpress.viz.common {
export interface FontOptions {
color?: string;
family?: string;
opacity?: number;
@@ -1300,8 +1305,8 @@ export interface FontOptions {
}
}
}
declare module DevExpress.viz.gauges {
interface CustomizeTextArgument {
declare module DevExpress.viz.gauges {
interface CustomizeTextArgument {
value: number;
valueText: string;
color: string;
@@ -1537,8 +1542,8 @@ interface CustomizeTextArgument {
pathModified?: boolean;
}
}
declare module DevExpress.viz.map {
interface TooltipOptions extends common.BaseTooltipOptions {
declare module DevExpress.viz.map {
interface TooltipOptions extends common.BaseTooltipOptions {
customizeText?: (arg: Proxy) => string;
customizeTooltip?: (arg: Proxy) => common.CustomizeTooltipResult;
borderColor?: string;
@@ -1634,8 +1639,8 @@ interface TooltipOptions extends common.BaseTooltipOptions {
coordinates(): Array<number>;
}
}
declare module DevExpress.viz.rangeSelector {
export interface SelectedRange {
declare module DevExpress.viz.rangeSelector {
export interface SelectedRange {
startValue: any; endValue: any;
}
interface CustomizeTextArgument {
@@ -1764,8 +1769,8 @@ export interface SelectedRange {
pathModified?: boolean;
}
}
declare module DevExpress.viz.sparklines {
interface z_SparklineTooltipFormatObject {
declare module DevExpress.viz.sparklines {
interface z_SparklineTooltipFormatObject {
firstValue?: string;
lastValue?: string;
maxValue?: string;
@@ -1839,7 +1844,7 @@ interface z_SparklineTooltipFormatObject {
}
}
interface JQuery {
dxChart(options?: DevExpress.viz.charts.ChartOptions): JQuery;
dxChart(options?: DevExpress.viz.charts.ChartOptions): JQuery;
dxChart(method: string, param1?:any, param2?:any): any;
dxPieChart(options?: DevExpress.viz.charts.PieOptions): JQuery;
dxPieChart(method: string, param1?: any, param2?: any): any;
+95 -91
View File
@@ -5,8 +5,8 @@
///<reference path="../jquery/jquery.d.ts" />
declare module DevExpress {
export function abstract(): void;
declare module DevExpress {
export function abstract(): void;
export var rtlEnabled: boolean;
export var hardwareBackButton: JQueryCallback;
interface Endpoint {
@@ -84,8 +84,8 @@ export function abstract(): void;
}): void;
}
}
declare module DevExpress.data {
export interface DataError extends Error {
declare module DevExpress.data {
export interface DataError extends Error {
httpStatus?: number;
errorDetails?: any;
}
@@ -205,7 +205,7 @@ export interface DataError extends Error {
export module queryAdapters {
export function odata(queryOptions: ODataQueryOptions): RemoteQuery;
}
export interface DataSourceOptions {
export interface DataSourceOptions {
map? (item: any): any;
postProcess? (result: any[]): any;
pageSize: number;
@@ -245,7 +245,7 @@ export interface DataSourceOptions {
load(): JQueryPromise<any>;
dispose(): void;
}
export interface StoreOptions {
export interface StoreOptions {
key?: any;
errorHandler?: ErrorHandler;
loaded?: (result: Array<any>) => void;
@@ -351,8 +351,8 @@ export interface StoreOptions {
objectLink(entityAlias: string, key: any): { __metadata: { uri: string }; };
}
}
declare module DevExpress.framework {
export interface dxViewOptions {
declare module DevExpress.framework {
export interface dxViewOptions {
name: string;
title?: string;
layout?: string;
@@ -690,8 +690,8 @@ export interface dxViewOptions {
[key: string]: { execute(e: any): void; }
};
}
declare module DevExpress.framework.html {
export interface ILayoutController {
declare module DevExpress.framework.html {
export interface ILayoutController {
viewReleased: JQueryCallback;
init(options: InitLayoutControllerOptions): void;
activate(): void;
@@ -793,7 +793,11 @@ export interface ILayoutController {
viewPort(): JQuery;
}
}
declare module DevExpress.ui {
declare module DevExpress.ui {
export var themes: {
current(): string;
current(themeName: string): void;
};
interface ViewportOptions {
allowPan?: boolean;
allowZoom?: boolean;
@@ -849,7 +853,7 @@ declare module DevExpress.ui {
export function confirm(options: DialogOptions): JQueryPromise<boolean>;
export function confirm(message: string, title?: string): JQueryPromise<boolean>;
}
export interface CollectionContainerWidgetOptions extends WidgetOptions {
export interface CollectionContainerWidgetOptions extends WidgetOptions {
items?: Array<any>;
itemTemplate?: any;
itemRender?: Function;
@@ -866,7 +870,7 @@ export interface CollectionContainerWidgetOptions extends WidgetOptions {
constructor(element: Element, options?: CollectionContainerWidgetOptions);
constructor(element: JQuery, options?: CollectionContainerWidgetOptions);
}
export interface WidgetOptions extends ComponentOptions {
export interface WidgetOptions extends ComponentOptions {
contentReadyAction?: any;
width?: any;
height?: any;
@@ -880,7 +884,7 @@ export interface WidgetOptions extends ComponentOptions {
repaint(): void;
addTemplate(template: ITemplate): void;
}
export interface dxEditorOptions extends WidgetOptions {
export interface dxEditorOptions extends WidgetOptions {
value?: any;
valueChangeAction?: any;
}
@@ -888,7 +892,7 @@ export interface dxEditorOptions extends WidgetOptions {
constructor(element: Element, options?: dxEditorOptions);
constructor(element: JQuery, options?: dxEditorOptions);
}
export interface dxAutocompleteOptions extends dxDropDownEditorOptions {
export interface dxAutocompleteOptions extends dxDropDownEditorOptions {
minSearchLength?: number;
searchTimeout?: number;
placeholder?: string;
@@ -904,7 +908,7 @@ export interface dxAutocompleteOptions extends dxDropDownEditorOptions {
constructor(element: Element, options?: dxAutocompleteOptions);
constructor(element: JQuery, options?: dxAutocompleteOptions);
}
export interface dxButtonOptions extends WidgetOptions {
export interface dxButtonOptions extends WidgetOptions {
type?: string;
text?: string;
icon?: string;
@@ -915,12 +919,12 @@ export interface dxButtonOptions extends WidgetOptions {
constructor(element: Element, options?: dxButtonOptions);
constructor(element: JQuery, options?: dxButtonOptions);
}
export interface dxCheckBoxOptions extends dxEditorOptions { }
export interface dxCheckBoxOptions extends dxEditorOptions { }
export class dxCheckBox extends dxEditor {
constructor(element: Element, options?: dxCheckBoxOptions);
constructor(element: JQuery, options?: dxCheckBoxOptions);
}
export interface dxCalendarOptions extends dxEditorOptions {
export interface dxCalendarOptions extends dxEditorOptions {
value?: Date;
min?: Date;
max?: Date;
@@ -930,7 +934,7 @@ export interface dxCalendarOptions extends dxEditorOptions {
constructor(element: Element, options?: dxEditorOptions);
constructor(element: JQuery, options?: dxEditorOptions);
}
export interface dxDateBoxOptions extends dxTextEditorOptions {
export interface dxDateBoxOptions extends dxTextEditorOptions {
format?: string;
useNativePicker?: boolean;
value?: Date;
@@ -946,7 +950,7 @@ export interface dxDateBoxOptions extends dxTextEditorOptions {
constructor(element: Element, options?: dxDateBoxOptions);
constructor(element: JQuery, options?: dxDateBoxOptions);
}
export interface dxTextEditorOptions extends dxEditorOptions {
export interface dxTextEditorOptions extends dxEditorOptions {
valueChangeEvent?: string;
placeholder?: string;
readOnly?: boolean;
@@ -970,7 +974,7 @@ export interface dxTextEditorOptions extends dxEditorOptions {
focus(): void;
blur(): void;
}
export interface dxListOptions extends CollectionContainerWidgetOptions {
export interface dxListOptions extends CollectionContainerWidgetOptions {
pullRefreshEnabled?: boolean;
autoPagingEnabled?: boolean;
scrollingEnabled?: boolean;
@@ -1036,7 +1040,7 @@ export interface dxListOptions extends CollectionContainerWidgetOptions {
scrollTo(targetLocation: number): void;
scrollTop(): number;
}
export interface dxLoadPanelOptions extends dxOverlayOptions {
export interface dxLoadPanelOptions extends dxOverlayOptions {
message?: string;
width?: number;
height?: number;
@@ -1052,7 +1056,7 @@ export interface dxLoadPanelOptions extends dxOverlayOptions {
show(): void;
toggle(showing: boolean): void;
}
export interface dxLookupOptions extends dxEditorOptions {
export interface dxLookupOptions extends dxEditorOptions {
dataSource?: data.DataSource;
displayValue?: string;
title?: string;
@@ -1104,7 +1108,7 @@ export interface dxLookupOptions extends dxEditorOptions {
close(): void;
open(): void;
}
export interface dxMapOptions extends WidgetOptions {
export interface dxMapOptions extends WidgetOptions {
location?: any;
width?: number;
height?: number;
@@ -1133,12 +1137,12 @@ export interface dxMapOptions extends WidgetOptions {
addRoute(routeOptions: any, callback: Function): JQueryPromise<any>;
removeRoute(route: any): void;
}
export interface dxNavBarOptions extends dxTabsOptions { }
export interface dxNavBarOptions extends dxTabsOptions { }
export class dxNavBar extends dxTabs {
constructor(element: Element, options?: dxNavBarOptions);
constructor(element: JQuery, options?: dxNavBarOptions);
}
export interface dxNumberBoxOptions extends dxTextEditorOptions {
export interface dxNumberBoxOptions extends dxTextEditorOptions {
min?: number;
max?: number;
value?: number;
@@ -1149,7 +1153,7 @@ export interface dxNumberBoxOptions extends dxTextEditorOptions {
constructor(element: Element, options?: dxNumberBoxOptions);
constructor(element: JQuery, options?: dxNumberBoxOptions);
}
export interface dxOverlayOptions extends WidgetOptions {
export interface dxOverlayOptions extends WidgetOptions {
activeStateEnabled?: boolean;
shading?: boolean;
closeOnOutsideClick?: boolean;
@@ -1171,7 +1175,7 @@ export interface dxOverlayOptions extends WidgetOptions {
show(): void;
toggle(showing: boolean): void;
}
export interface dxPopupOptions extends dxOverlayOptions {
export interface dxPopupOptions extends dxOverlayOptions {
title?: string;
showTitle?: boolean;
fullScreen?: boolean;
@@ -1185,21 +1189,21 @@ export interface dxPopupOptions extends dxOverlayOptions {
constructor(element: Element, options?: dxPopupOptions);
constructor(element: JQuery, options?: dxPopupOptions);
}
export interface dxPopoverOptions extends dxPopupOptions {
export interface dxPopoverOptions extends dxPopupOptions {
target?: any;
}
export class dxPopover extends dxPopup {
constructor(element: Element, options?: dxPopoverOptions);
constructor(element: JQuery, options?: dxPopoverOptions);
}
export interface dxTooltipOptions extends dxPopoverOptions {
export interface dxTooltipOptions extends dxPopoverOptions {
target?: any;
}
export class dxTooltip extends dxPopover {
constructor(element: Element, options?: dxTooltipOptions);
constructor(element: JQuery, options?: dxTooltipOptions);
}
export interface dxRadioGroupOptions extends CollectionContainerWidgetOptions {
export interface dxRadioGroupOptions extends CollectionContainerWidgetOptions {
layout?: string;
name?: string;
value?: Object;
@@ -1209,7 +1213,7 @@ export interface dxRadioGroupOptions extends CollectionContainerWidgetOptions {
constructor(element: Element, options?: dxRadioGroupOptions);
constructor(element: JQuery, options?: dxRadioGroupOptions);
}
export interface dxRangeSliderOptions extends dxSliderOptions {
export interface dxRangeSliderOptions extends dxSliderOptions {
start?: number;
end?: number;
}
@@ -1217,7 +1221,7 @@ export interface dxRangeSliderOptions extends dxSliderOptions {
constructor(element: Element, options?: dxRangeSliderOptions);
constructor(element: JQuery, options?: dxRangeSliderOptions);
}
export interface dxScrollableOptions extends ComponentOptions {
export interface dxScrollableOptions extends ComponentOptions {
startAction?: any;
scrollAction?: any;
endAction?: any;
@@ -1247,7 +1251,7 @@ export interface dxScrollableOptions extends ComponentOptions {
scrollTo(targetLocation: number): void;
scrollTo(targetLocation: Object): void;
}
export interface dxScrollViewOptions extends dxScrollableOptions {
export interface dxScrollViewOptions extends dxScrollableOptions {
pullingDownText?: string;
pulledDownText?: string;
refreshingText?: string;
@@ -1262,7 +1266,7 @@ export interface dxScrollViewOptions extends dxScrollableOptions {
toggleLoading(showOrHide: boolean): void;
refresh(): void;
}
export interface dxSelectBoxOptions extends dxAutocompleteOptions {
export interface dxSelectBoxOptions extends dxAutocompleteOptions {
fieldTemplate?: any;
displayValue?: string;
multiSelectEnabled?: boolean;
@@ -1274,7 +1278,7 @@ export interface dxSelectBoxOptions extends dxAutocompleteOptions {
constructor(element: Element, options?: dxSelectBoxOptions);
constructor(element: JQuery, options?: dxSelectBoxOptions);
}
export interface dxSliderOptions extends dxEditorOptions {
export interface dxSliderOptions extends dxEditorOptions {
min?: number;
max?: number;
step?: number;
@@ -1295,12 +1299,12 @@ export interface dxSliderOptions extends dxEditorOptions {
constructor(element: Element, options?: dxSliderOptions);
constructor(element: JQuery, options?: dxSliderOptions);
}
export interface dxTabsOptions extends CollectionContainerWidgetOptions { }
export interface dxTabsOptions extends CollectionContainerWidgetOptions { }
export class dxTabs extends CollectionContainerWidget {
constructor(element: Element, options?: dxTabsOptions);
constructor(element: JQuery, options?: dxTabsOptions);
}
export interface dxTextAreaOptions extends dxTextEditorOptions {
export interface dxTextAreaOptions extends dxTextEditorOptions {
cols?: number;
rows?: number;
}
@@ -1308,14 +1312,14 @@ export interface dxTextAreaOptions extends dxTextEditorOptions {
constructor(element: Element, options?: dxTextAreaOptions);
constructor(element: JQuery, options?: dxTextAreaOptions);
}
export interface dxTextBoxOptions extends dxTextEditorOptions {
export interface dxTextBoxOptions extends dxTextEditorOptions {
maxLength?: any;
}
export class dxTextBox extends dxTextEditor {
constructor(element: Element, options?: dxTextBoxOptions);
constructor(element: JQuery, options?: dxTextBoxOptions);
}
export interface dxToastOptions extends dxOverlayOptions {
export interface dxToastOptions extends dxOverlayOptions {
message?: string;
type?: string;
displayTime?: number;
@@ -1324,7 +1328,7 @@ export interface dxToastOptions extends dxOverlayOptions {
constructor(element: Element, options?: dxToastOptions);
constructor(element: JQuery, options?: dxToastOptions);
}
export interface dxToolbarOptions extends CollectionContainerWidgetOptions {
export interface dxToolbarOptions extends CollectionContainerWidgetOptions {
menuItemRender?: Function;
menuItemTemplate?: any;
submenuType?: string;
@@ -1334,7 +1338,7 @@ export interface dxToolbarOptions extends CollectionContainerWidgetOptions {
constructor(element: Element, options?: dxToolbarOptions);
constructor(element: JQuery, options?: dxToolbarOptions);
}
export interface dxDropDownEditorOptions extends dxTextBoxOptions {
export interface dxDropDownEditorOptions extends dxTextBoxOptions {
closeAction?: any;
openAction?: any;
}
@@ -1342,14 +1346,14 @@ export interface dxDropDownEditorOptions extends dxTextBoxOptions {
constructor(element: Element, options?: dxDropDownEditorOptions);
constructor(element: JQuery, options?: dxDropDownEditorOptions);
}
export interface dxLoadIndicatorOptions extends WidgetOptions {
export interface dxLoadIndicatorOptions extends WidgetOptions {
indicatorSrc?: string;
}
export class dxLoadIndicator extends Widget {
constructor(element: Element, options?: dxLoadIndicatorOptions);
constructor(element: JQuery, options?: dxLoadIndicatorOptions);
}
export interface dxMultiViewOptions extends CollectionContainerWidgetOptions {
export interface dxMultiViewOptions extends CollectionContainerWidgetOptions {
loop?: boolean;
swipeEnabled?: boolean;
animationEnabled?: boolean;
@@ -1359,7 +1363,7 @@ export interface dxMultiViewOptions extends CollectionContainerWidgetOptions {
constructor(element: Element, options?: dxMultiViewOptions);
constructor(element: JQuery, options?: dxMultiViewOptions);
}
export interface dxGalleryOptions extends CollectionContainerWidgetOptions {
export interface dxGalleryOptions extends CollectionContainerWidgetOptions {
activeStateEnabled?: boolean;
animationDuration?: number;
loop?: boolean;
@@ -1377,7 +1381,7 @@ export interface dxGalleryOptions extends CollectionContainerWidgetOptions {
prevItem(animation?: boolean): JQueryPromise<dxGallery>;
nextItem(animation?: boolean): JQueryPromise<dxGallery>;
}
export interface dxActionSheetOptions extends CollectionContainerWidgetOptions {
export interface dxActionSheetOptions extends CollectionContainerWidgetOptions {
usePopover?: boolean;
target?: any;
title?: string;
@@ -1394,7 +1398,7 @@ export interface dxActionSheetOptions extends CollectionContainerWidgetOptions {
show(): void;
hide(): void;
}
export interface dxDropDownMenuOptions extends WidgetOptions {
export interface dxDropDownMenuOptions extends WidgetOptions {
items?: Array<any>;
itemClickAction?: any;
dataSource?: data.DataSource;
@@ -1410,7 +1414,7 @@ export interface dxDropDownMenuOptions extends WidgetOptions {
constructor(element: Element, options?: dxDropDownMenuOptions);
constructor(element: JQuery, options?: dxDropDownMenuOptions);
}
export interface dxPanoramaOptions extends CollectionContainerWidgetOptions {
export interface dxPanoramaOptions extends CollectionContainerWidgetOptions {
title?: string;
backgroundImage?: any;
}
@@ -1418,12 +1422,12 @@ export interface dxPanoramaOptions extends CollectionContainerWidgetOptions {
constructor(element: Element, options?: dxPanoramaOptions);
constructor(element: JQuery, options?: dxPanoramaOptions);
}
export interface dxPivotOptions extends CollectionContainerWidgetOptions { }
export interface dxPivotOptions extends CollectionContainerWidgetOptions { }
export class dxPivot extends CollectionContainerWidget {
constructor(element: Element, options?: dxPivotOptions);
constructor(element: JQuery, options?: dxPivotOptions);
}
export interface dxSwitchOptions extends dxEditorOptions {
export interface dxSwitchOptions extends dxEditorOptions {
onText?: string;
offText?: string;
}
@@ -1431,7 +1435,7 @@ export interface dxSwitchOptions extends dxEditorOptions {
constructor(element: Element, options?: dxSwitchOptions);
constructor(element: JQuery, options?: dxSwitchOptions);
}
export interface dxTileViewOptions extends CollectionContainerWidgetOptions {
export interface dxTileViewOptions extends CollectionContainerWidgetOptions {
bounceEnabled?: boolean;
showScrollbar?: boolean;
listHeight?: number;
@@ -1443,7 +1447,7 @@ export interface dxTileViewOptions extends CollectionContainerWidgetOptions {
constructor(element: Element, options?: dxTileViewOptions);
constructor(element: JQuery, options?: dxTileViewOptions);
}
export interface dxSlideOutOptions extends CollectionContainerWidgetOptions {
export interface dxSlideOutOptions extends CollectionContainerWidgetOptions {
activeStateEnabled?: boolean;
menuItemRender? (itemData: any, itemIndex: number, itemElement: Element): any;
menuItemTemplate?: any;
@@ -1461,43 +1465,43 @@ export interface dxSlideOutOptions extends CollectionContainerWidgetOptions {
toggleMenuVisibility(showing?: boolean): JQueryPromise<dxSlideOut>;
}
}
interface JQuery {
dxAutocomplete(options?: DevExpress.ui.dxAutocompleteOptions): JQuery;
dxButton(options?: DevExpress.ui.dxButtonOptions): JQuery;
dxCheckBox(options?: DevExpress.ui.dxCheckBoxOptions): JQuery;
dxCalendar(options?: DevExpress.ui.dxCalendarOptions): JQuery;
dxDateBox(options?: DevExpress.ui.dxDateBoxOptions): JQuery;
dxTextEditor(options?: DevExpress.ui.dxTextEditorOptions): JQuery;
dxList(options?: DevExpress.ui.dxListOptions): JQuery;
dxLoadPanel(options?: DevExpress.ui.dxLoadPanelOptions): JQuery;
dxLookup(options?: DevExpress.ui.dxLookupOptions): JQuery;
dxMap(options?: DevExpress.ui.dxMapOptions): JQuery;
dxNavBar(options?: DevExpress.ui.dxNavBarOptions): JQuery;
dxNumberBox(options?: DevExpress.ui.dxNumberBoxOptions): JQuery;
dxOverlay(options?: DevExpress.ui.dxOverlayOptions): JQuery;
dxPopup(options?: DevExpress.ui.dxPopupOptions): JQuery;
dxPopover(options?: DevExpress.ui.dxPopoverOptions): JQuery;
dxTooltip(options?: DevExpress.ui.dxTooltipOptions): JQuery;
dxRadioGroup(options?: DevExpress.ui.dxRadioGroupOptions): JQuery;
dxRangeSlider(options?: DevExpress.ui.dxRangeSliderOptions): JQuery;
dxScrollable(options?: DevExpress.ui.dxScrollableOptions): JQuery;
dxScrollView(options?: DevExpress.ui.dxScrollViewOptions): JQuery;
dxSelectBox(options?: DevExpress.ui.dxSelectBoxOptions): JQuery;
dxSlider(options?: DevExpress.ui.dxSliderOptions): JQuery;
dxTabs(options?: DevExpress.ui.dxTabsOptions): JQuery;
dxTextArea(options?: DevExpress.ui.dxTextAreaOptions): JQuery;
dxTextBox(options?: DevExpress.ui.dxTextBoxOptions): JQuery;
dxToast(options?: DevExpress.ui.dxToastOptions): JQuery;
dxToolbar(options?: DevExpress.ui.dxToolbarOptions): JQuery;
dxDropDownEditor(options?: DevExpress.ui.dxDropDownEditorOptions): JQuery;
dxLoadIndicator(options?: DevExpress.ui.dxLoadIndicatorOptions): JQuery;
dxMultiView(options?: DevExpress.ui.dxMultiViewOptions): JQuery;
dxGallery(options?: DevExpress.ui.dxGalleryOptions): JQuery;
dxActionSheet(options?: DevExpress.ui.dxActionSheetOptions): JQuery;
dxDropDownMenu(options?: DevExpress.ui.dxDropDownMenuOptions): JQuery;
dxPanorama(options?: DevExpress.ui.dxPanoramaOptions): JQuery;
dxPivot(options?: DevExpress.ui.dxPivotOptions): JQuery;
dxSwitch(options?: DevExpress.ui.dxSwitchOptions): JQuery;
dxTileView(options?: DevExpress.ui.dxTileViewOptions): JQuery;
dxSlideOut(options?: DevExpress.ui.dxSlideOutOptions): JQuery;
interface JQuery {
dxAutocomplete(options?: DevExpress.ui.dxAutocompleteOptions): JQuery;
dxButton(options?: DevExpress.ui.dxButtonOptions): JQuery;
dxCheckBox(options?: DevExpress.ui.dxCheckBoxOptions): JQuery;
dxCalendar(options?: DevExpress.ui.dxCalendarOptions): JQuery;
dxDateBox(options?: DevExpress.ui.dxDateBoxOptions): JQuery;
dxTextEditor(options?: DevExpress.ui.dxTextEditorOptions): JQuery;
dxList(options?: DevExpress.ui.dxListOptions): JQuery;
dxLoadPanel(options?: DevExpress.ui.dxLoadPanelOptions): JQuery;
dxLookup(options?: DevExpress.ui.dxLookupOptions): JQuery;
dxMap(options?: DevExpress.ui.dxMapOptions): JQuery;
dxNavBar(options?: DevExpress.ui.dxNavBarOptions): JQuery;
dxNumberBox(options?: DevExpress.ui.dxNumberBoxOptions): JQuery;
dxOverlay(options?: DevExpress.ui.dxOverlayOptions): JQuery;
dxPopup(options?: DevExpress.ui.dxPopupOptions): JQuery;
dxPopover(options?: DevExpress.ui.dxPopoverOptions): JQuery;
dxTooltip(options?: DevExpress.ui.dxTooltipOptions): JQuery;
dxRadioGroup(options?: DevExpress.ui.dxRadioGroupOptions): JQuery;
dxRangeSlider(options?: DevExpress.ui.dxRangeSliderOptions): JQuery;
dxScrollable(options?: DevExpress.ui.dxScrollableOptions): JQuery;
dxScrollView(options?: DevExpress.ui.dxScrollViewOptions): JQuery;
dxSelectBox(options?: DevExpress.ui.dxSelectBoxOptions): JQuery;
dxSlider(options?: DevExpress.ui.dxSliderOptions): JQuery;
dxTabs(options?: DevExpress.ui.dxTabsOptions): JQuery;
dxTextArea(options?: DevExpress.ui.dxTextAreaOptions): JQuery;
dxTextBox(options?: DevExpress.ui.dxTextBoxOptions): JQuery;
dxToast(options?: DevExpress.ui.dxToastOptions): JQuery;
dxToolbar(options?: DevExpress.ui.dxToolbarOptions): JQuery;
dxDropDownEditor(options?: DevExpress.ui.dxDropDownEditorOptions): JQuery;
dxLoadIndicator(options?: DevExpress.ui.dxLoadIndicatorOptions): JQuery;
dxMultiView(options?: DevExpress.ui.dxMultiViewOptions): JQuery;
dxGallery(options?: DevExpress.ui.dxGalleryOptions): JQuery;
dxActionSheet(options?: DevExpress.ui.dxActionSheetOptions): JQuery;
dxDropDownMenu(options?: DevExpress.ui.dxDropDownMenuOptions): JQuery;
dxPanorama(options?: DevExpress.ui.dxPanoramaOptions): JQuery;
dxPivot(options?: DevExpress.ui.dxPivotOptions): JQuery;
dxSwitch(options?: DevExpress.ui.dxSwitchOptions): JQuery;
dxTileView(options?: DevExpress.ui.dxTileViewOptions): JQuery;
dxSlideOut(options?: DevExpress.ui.dxSlideOutOptions): JQuery;
}
+87 -83
View File
@@ -5,8 +5,8 @@
///<reference path="../jquery/jquery.d.ts" />
declare module DevExpress {
export function abstract(): void;
declare module DevExpress {
export function abstract(): void;
export var rtlEnabled: boolean;
export var hardwareBackButton: JQueryCallback;
interface Endpoint {
@@ -84,8 +84,8 @@ export function abstract(): void;
}): void;
}
}
declare module DevExpress.data {
export interface DataError extends Error {
declare module DevExpress.data {
export interface DataError extends Error {
httpStatus?: number;
errorDetails?: any;
}
@@ -205,7 +205,7 @@ export interface DataError extends Error {
export module queryAdapters {
export function odata(queryOptions: ODataQueryOptions): RemoteQuery;
}
export interface DataSourceOptions {
export interface DataSourceOptions {
map? (item: any): any;
postProcess? (result: any[]): any;
pageSize: number;
@@ -245,7 +245,7 @@ export interface DataSourceOptions {
load(): JQueryPromise<any>;
dispose(): void;
}
export interface StoreOptions {
export interface StoreOptions {
key?: any;
errorHandler?: ErrorHandler;
loaded?: (result: Array<any>) => void;
@@ -351,8 +351,8 @@ export interface StoreOptions {
objectLink(entityAlias: string, key: any): { __metadata: { uri: string }; };
}
}
declare module DevExpress.framework {
export interface dxViewOptions {
declare module DevExpress.framework {
export interface dxViewOptions {
name: string;
title?: string;
layout?: string;
@@ -690,8 +690,8 @@ export interface dxViewOptions {
[key: string]: { execute(e: any): void; }
};
}
declare module DevExpress.framework.html {
export interface ILayoutController {
declare module DevExpress.framework.html {
export interface ILayoutController {
viewReleased: JQueryCallback;
init(options: InitLayoutControllerOptions): void;
activate(): void;
@@ -793,7 +793,11 @@ export interface ILayoutController {
viewPort(): JQuery;
}
}
declare module DevExpress.ui {
declare module DevExpress.ui {
export var themes: {
current(): string;
current(themeName: string): void;
};
interface ViewportOptions {
allowPan?: boolean;
allowZoom?: boolean;
@@ -849,7 +853,7 @@ declare module DevExpress.ui {
export function confirm(options: DialogOptions): JQueryPromise<boolean>;
export function confirm(message: string, title?: string): JQueryPromise<boolean>;
}
export interface CollectionContainerWidgetOptions extends WidgetOptions {
export interface CollectionContainerWidgetOptions extends WidgetOptions {
items?: Array<any>;
itemTemplate?: any;
itemRender?: Function;
@@ -866,7 +870,7 @@ export interface CollectionContainerWidgetOptions extends WidgetOptions {
constructor(element: Element, options?: CollectionContainerWidgetOptions);
constructor(element: JQuery, options?: CollectionContainerWidgetOptions);
}
export interface WidgetOptions extends ComponentOptions {
export interface WidgetOptions extends ComponentOptions {
contentReadyAction?: any;
width?: any;
height?: any;
@@ -880,7 +884,7 @@ export interface WidgetOptions extends ComponentOptions {
repaint(): void;
addTemplate(template: ITemplate): void;
}
export interface dxEditorOptions extends WidgetOptions {
export interface dxEditorOptions extends WidgetOptions {
value?: any;
valueChangeAction?: any;
}
@@ -888,7 +892,7 @@ export interface dxEditorOptions extends WidgetOptions {
constructor(element: Element, options?: dxEditorOptions);
constructor(element: JQuery, options?: dxEditorOptions);
}
export interface dxAutocompleteOptions extends dxDropDownEditorOptions {
export interface dxAutocompleteOptions extends dxDropDownEditorOptions {
minSearchLength?: number;
searchTimeout?: number;
placeholder?: string;
@@ -904,7 +908,7 @@ export interface dxAutocompleteOptions extends dxDropDownEditorOptions {
constructor(element: Element, options?: dxAutocompleteOptions);
constructor(element: JQuery, options?: dxAutocompleteOptions);
}
export interface dxButtonOptions extends WidgetOptions {
export interface dxButtonOptions extends WidgetOptions {
type?: string;
text?: string;
icon?: string;
@@ -915,12 +919,12 @@ export interface dxButtonOptions extends WidgetOptions {
constructor(element: Element, options?: dxButtonOptions);
constructor(element: JQuery, options?: dxButtonOptions);
}
export interface dxCheckBoxOptions extends dxEditorOptions { }
export interface dxCheckBoxOptions extends dxEditorOptions { }
export class dxCheckBox extends dxEditor {
constructor(element: Element, options?: dxCheckBoxOptions);
constructor(element: JQuery, options?: dxCheckBoxOptions);
}
export interface dxCalendarOptions extends dxEditorOptions {
export interface dxCalendarOptions extends dxEditorOptions {
value?: Date;
min?: Date;
max?: Date;
@@ -930,7 +934,7 @@ export interface dxCalendarOptions extends dxEditorOptions {
constructor(element: Element, options?: dxEditorOptions);
constructor(element: JQuery, options?: dxEditorOptions);
}
export interface dxDateBoxOptions extends dxTextEditorOptions {
export interface dxDateBoxOptions extends dxTextEditorOptions {
format?: string;
useNativePicker?: boolean;
value?: Date;
@@ -946,7 +950,7 @@ export interface dxDateBoxOptions extends dxTextEditorOptions {
constructor(element: Element, options?: dxDateBoxOptions);
constructor(element: JQuery, options?: dxDateBoxOptions);
}
export interface dxTextEditorOptions extends dxEditorOptions {
export interface dxTextEditorOptions extends dxEditorOptions {
valueChangeEvent?: string;
placeholder?: string;
readOnly?: boolean;
@@ -970,7 +974,7 @@ export interface dxTextEditorOptions extends dxEditorOptions {
focus(): void;
blur(): void;
}
export interface dxListOptions extends CollectionContainerWidgetOptions {
export interface dxListOptions extends CollectionContainerWidgetOptions {
pullRefreshEnabled?: boolean;
autoPagingEnabled?: boolean;
scrollingEnabled?: boolean;
@@ -1036,7 +1040,7 @@ export interface dxListOptions extends CollectionContainerWidgetOptions {
scrollTo(targetLocation: number): void;
scrollTop(): number;
}
export interface dxLoadPanelOptions extends dxOverlayOptions {
export interface dxLoadPanelOptions extends dxOverlayOptions {
message?: string;
width?: number;
height?: number;
@@ -1052,7 +1056,7 @@ export interface dxLoadPanelOptions extends dxOverlayOptions {
show(): void;
toggle(showing: boolean): void;
}
export interface dxLookupOptions extends dxEditorOptions {
export interface dxLookupOptions extends dxEditorOptions {
dataSource?: data.DataSource;
displayValue?: string;
title?: string;
@@ -1104,7 +1108,7 @@ export interface dxLookupOptions extends dxEditorOptions {
close(): void;
open(): void;
}
export interface dxMapOptions extends WidgetOptions {
export interface dxMapOptions extends WidgetOptions {
location?: any;
width?: number;
height?: number;
@@ -1133,12 +1137,12 @@ export interface dxMapOptions extends WidgetOptions {
addRoute(routeOptions: any, callback: Function): JQueryPromise<any>;
removeRoute(route: any): void;
}
export interface dxNavBarOptions extends dxTabsOptions { }
export interface dxNavBarOptions extends dxTabsOptions { }
export class dxNavBar extends dxTabs {
constructor(element: Element, options?: dxNavBarOptions);
constructor(element: JQuery, options?: dxNavBarOptions);
}
export interface dxNumberBoxOptions extends dxTextEditorOptions {
export interface dxNumberBoxOptions extends dxTextEditorOptions {
min?: number;
max?: number;
value?: number;
@@ -1149,7 +1153,7 @@ export interface dxNumberBoxOptions extends dxTextEditorOptions {
constructor(element: Element, options?: dxNumberBoxOptions);
constructor(element: JQuery, options?: dxNumberBoxOptions);
}
export interface dxOverlayOptions extends WidgetOptions {
export interface dxOverlayOptions extends WidgetOptions {
activeStateEnabled?: boolean;
shading?: boolean;
closeOnOutsideClick?: boolean;
@@ -1171,7 +1175,7 @@ export interface dxOverlayOptions extends WidgetOptions {
show(): void;
toggle(showing: boolean): void;
}
export interface dxPopupOptions extends dxOverlayOptions {
export interface dxPopupOptions extends dxOverlayOptions {
title?: string;
showTitle?: boolean;
fullScreen?: boolean;
@@ -1185,21 +1189,21 @@ export interface dxPopupOptions extends dxOverlayOptions {
constructor(element: Element, options?: dxPopupOptions);
constructor(element: JQuery, options?: dxPopupOptions);
}
export interface dxPopoverOptions extends dxPopupOptions {
export interface dxPopoverOptions extends dxPopupOptions {
target?: any;
}
export class dxPopover extends dxPopup {
constructor(element: Element, options?: dxPopoverOptions);
constructor(element: JQuery, options?: dxPopoverOptions);
}
export interface dxTooltipOptions extends dxPopoverOptions {
export interface dxTooltipOptions extends dxPopoverOptions {
target?: any;
}
export class dxTooltip extends dxPopover {
constructor(element: Element, options?: dxTooltipOptions);
constructor(element: JQuery, options?: dxTooltipOptions);
}
export interface dxRadioGroupOptions extends CollectionContainerWidgetOptions {
export interface dxRadioGroupOptions extends CollectionContainerWidgetOptions {
layout?: string;
name?: string;
value?: Object;
@@ -1209,7 +1213,7 @@ export interface dxRadioGroupOptions extends CollectionContainerWidgetOptions {
constructor(element: Element, options?: dxRadioGroupOptions);
constructor(element: JQuery, options?: dxRadioGroupOptions);
}
export interface dxRangeSliderOptions extends dxSliderOptions {
export interface dxRangeSliderOptions extends dxSliderOptions {
start?: number;
end?: number;
}
@@ -1217,7 +1221,7 @@ export interface dxRangeSliderOptions extends dxSliderOptions {
constructor(element: Element, options?: dxRangeSliderOptions);
constructor(element: JQuery, options?: dxRangeSliderOptions);
}
export interface dxScrollableOptions extends ComponentOptions {
export interface dxScrollableOptions extends ComponentOptions {
startAction?: any;
scrollAction?: any;
endAction?: any;
@@ -1247,7 +1251,7 @@ export interface dxScrollableOptions extends ComponentOptions {
scrollTo(targetLocation: number): void;
scrollTo(targetLocation: Object): void;
}
export interface dxScrollViewOptions extends dxScrollableOptions {
export interface dxScrollViewOptions extends dxScrollableOptions {
pullingDownText?: string;
pulledDownText?: string;
refreshingText?: string;
@@ -1262,7 +1266,7 @@ export interface dxScrollViewOptions extends dxScrollableOptions {
toggleLoading(showOrHide: boolean): void;
refresh(): void;
}
export interface dxSelectBoxOptions extends dxAutocompleteOptions {
export interface dxSelectBoxOptions extends dxAutocompleteOptions {
fieldTemplate?: any;
displayValue?: string;
multiSelectEnabled?: boolean;
@@ -1274,7 +1278,7 @@ export interface dxSelectBoxOptions extends dxAutocompleteOptions {
constructor(element: Element, options?: dxSelectBoxOptions);
constructor(element: JQuery, options?: dxSelectBoxOptions);
}
export interface dxSliderOptions extends dxEditorOptions {
export interface dxSliderOptions extends dxEditorOptions {
min?: number;
max?: number;
step?: number;
@@ -1295,12 +1299,12 @@ export interface dxSliderOptions extends dxEditorOptions {
constructor(element: Element, options?: dxSliderOptions);
constructor(element: JQuery, options?: dxSliderOptions);
}
export interface dxTabsOptions extends CollectionContainerWidgetOptions { }
export interface dxTabsOptions extends CollectionContainerWidgetOptions { }
export class dxTabs extends CollectionContainerWidget {
constructor(element: Element, options?: dxTabsOptions);
constructor(element: JQuery, options?: dxTabsOptions);
}
export interface dxTextAreaOptions extends dxTextEditorOptions {
export interface dxTextAreaOptions extends dxTextEditorOptions {
cols?: number;
rows?: number;
}
@@ -1308,14 +1312,14 @@ export interface dxTextAreaOptions extends dxTextEditorOptions {
constructor(element: Element, options?: dxTextAreaOptions);
constructor(element: JQuery, options?: dxTextAreaOptions);
}
export interface dxTextBoxOptions extends dxTextEditorOptions {
export interface dxTextBoxOptions extends dxTextEditorOptions {
maxLength?: any;
}
export class dxTextBox extends dxTextEditor {
constructor(element: Element, options?: dxTextBoxOptions);
constructor(element: JQuery, options?: dxTextBoxOptions);
}
export interface dxToastOptions extends dxOverlayOptions {
export interface dxToastOptions extends dxOverlayOptions {
message?: string;
type?: string;
displayTime?: number;
@@ -1324,7 +1328,7 @@ export interface dxToastOptions extends dxOverlayOptions {
constructor(element: Element, options?: dxToastOptions);
constructor(element: JQuery, options?: dxToastOptions);
}
export interface dxToolbarOptions extends CollectionContainerWidgetOptions {
export interface dxToolbarOptions extends CollectionContainerWidgetOptions {
menuItemRender?: Function;
menuItemTemplate?: any;
submenuType?: string;
@@ -1334,7 +1338,7 @@ export interface dxToolbarOptions extends CollectionContainerWidgetOptions {
constructor(element: Element, options?: dxToolbarOptions);
constructor(element: JQuery, options?: dxToolbarOptions);
}
export interface dxDropDownEditorOptions extends dxTextBoxOptions {
export interface dxDropDownEditorOptions extends dxTextBoxOptions {
closeAction?: any;
openAction?: any;
}
@@ -1342,14 +1346,14 @@ export interface dxDropDownEditorOptions extends dxTextBoxOptions {
constructor(element: Element, options?: dxDropDownEditorOptions);
constructor(element: JQuery, options?: dxDropDownEditorOptions);
}
export interface dxLoadIndicatorOptions extends WidgetOptions {
export interface dxLoadIndicatorOptions extends WidgetOptions {
indicatorSrc?: string;
}
export class dxLoadIndicator extends Widget {
constructor(element: Element, options?: dxLoadIndicatorOptions);
constructor(element: JQuery, options?: dxLoadIndicatorOptions);
}
export interface dxMultiViewOptions extends CollectionContainerWidgetOptions {
export interface dxMultiViewOptions extends CollectionContainerWidgetOptions {
loop?: boolean;
swipeEnabled?: boolean;
animationEnabled?: boolean;
@@ -1359,7 +1363,7 @@ export interface dxMultiViewOptions extends CollectionContainerWidgetOptions {
constructor(element: Element, options?: dxMultiViewOptions);
constructor(element: JQuery, options?: dxMultiViewOptions);
}
export interface dxGalleryOptions extends CollectionContainerWidgetOptions {
export interface dxGalleryOptions extends CollectionContainerWidgetOptions {
activeStateEnabled?: boolean;
animationDuration?: number;
loop?: boolean;
@@ -1377,7 +1381,7 @@ export interface dxGalleryOptions extends CollectionContainerWidgetOptions {
prevItem(animation?: boolean): JQueryPromise<dxGallery>;
nextItem(animation?: boolean): JQueryPromise<dxGallery>;
}
export interface dxDataGridFilterDescriptions {
export interface dxDataGridFilterDescriptions {
'='?: string;
'<>'?: string;
'<'?: string;
@@ -1562,7 +1566,7 @@ export interface dxDataGridFilterDescriptions {
isScrollbarVisible: () => boolean;
getTopVisibleRowData: () => {};
}
export interface dxMenuOptions extends CollectionContainerWidgetOptions {
export interface dxMenuOptions extends CollectionContainerWidgetOptions {
orientation?: string;
submenuDirection?: string;
showFirstSubmenuMode?: string;
@@ -1595,7 +1599,7 @@ export interface dxMenuOptions extends CollectionContainerWidgetOptions {
constructor(element: Element, options?: dxContextMenuOptions);
constructor(element: JQuery, options?: dxContextMenuOptions);
}
export interface dxColorPickerOptions extends dxDropDownEditorOptions {
export interface dxColorPickerOptions extends dxDropDownEditorOptions {
editAlphaChannel?: boolean;
applyButtonText?: string;
cancelButtonText?: string;
@@ -1605,40 +1609,40 @@ export interface dxColorPickerOptions extends dxDropDownEditorOptions {
constructor(element: JQuery, options?: dxColorPickerOptions);
}
}
interface JQuery {
dxAutocomplete(options?: DevExpress.ui.dxAutocompleteOptions): JQuery;
dxButton(options?: DevExpress.ui.dxButtonOptions): JQuery;
dxCheckBox(options?: DevExpress.ui.dxCheckBoxOptions): JQuery;
dxCalendar(options?: DevExpress.ui.dxCalendarOptions): JQuery;
dxDateBox(options?: DevExpress.ui.dxDateBoxOptions): JQuery;
dxTextEditor(options?: DevExpress.ui.dxTextEditorOptions): JQuery;
dxList(options?: DevExpress.ui.dxListOptions): JQuery;
dxLoadPanel(options?: DevExpress.ui.dxLoadPanelOptions): JQuery;
dxLookup(options?: DevExpress.ui.dxLookupOptions): JQuery;
dxMap(options?: DevExpress.ui.dxMapOptions): JQuery;
dxNavBar(options?: DevExpress.ui.dxNavBarOptions): JQuery;
dxNumberBox(options?: DevExpress.ui.dxNumberBoxOptions): JQuery;
dxOverlay(options?: DevExpress.ui.dxOverlayOptions): JQuery;
dxPopup(options?: DevExpress.ui.dxPopupOptions): JQuery;
dxPopover(options?: DevExpress.ui.dxPopoverOptions): JQuery;
dxTooltip(options?: DevExpress.ui.dxTooltipOptions): JQuery;
dxRadioGroup(options?: DevExpress.ui.dxRadioGroupOptions): JQuery;
dxRangeSlider(options?: DevExpress.ui.dxRangeSliderOptions): JQuery;
dxScrollable(options?: DevExpress.ui.dxScrollableOptions): JQuery;
dxScrollView(options?: DevExpress.ui.dxScrollViewOptions): JQuery;
dxSelectBox(options?: DevExpress.ui.dxSelectBoxOptions): JQuery;
dxSlider(options?: DevExpress.ui.dxSliderOptions): JQuery;
dxTabs(options?: DevExpress.ui.dxTabsOptions): JQuery;
dxTextArea(options?: DevExpress.ui.dxTextAreaOptions): JQuery;
dxTextBox(options?: DevExpress.ui.dxTextBoxOptions): JQuery;
dxToast(options?: DevExpress.ui.dxToastOptions): JQuery;
dxToolbar(options?: DevExpress.ui.dxToolbarOptions): JQuery;
dxDropDownEditor(options?: DevExpress.ui.dxDropDownEditorOptions): JQuery;
dxLoadIndicator(options?: DevExpress.ui.dxLoadIndicatorOptions): JQuery;
dxMultiView(options?: DevExpress.ui.dxMultiViewOptions): JQuery;
dxGallery(options?: DevExpress.ui.dxGalleryOptions): JQuery;
dxDataGrid(options?: DevExpress.ui.dxDataGridOptions): JQuery;
dxMenu(options?: DevExpress.ui.dxMenuOptions): JQuery;
interface JQuery {
dxAutocomplete(options?: DevExpress.ui.dxAutocompleteOptions): JQuery;
dxButton(options?: DevExpress.ui.dxButtonOptions): JQuery;
dxCheckBox(options?: DevExpress.ui.dxCheckBoxOptions): JQuery;
dxCalendar(options?: DevExpress.ui.dxCalendarOptions): JQuery;
dxDateBox(options?: DevExpress.ui.dxDateBoxOptions): JQuery;
dxTextEditor(options?: DevExpress.ui.dxTextEditorOptions): JQuery;
dxList(options?: DevExpress.ui.dxListOptions): JQuery;
dxLoadPanel(options?: DevExpress.ui.dxLoadPanelOptions): JQuery;
dxLookup(options?: DevExpress.ui.dxLookupOptions): JQuery;
dxMap(options?: DevExpress.ui.dxMapOptions): JQuery;
dxNavBar(options?: DevExpress.ui.dxNavBarOptions): JQuery;
dxNumberBox(options?: DevExpress.ui.dxNumberBoxOptions): JQuery;
dxOverlay(options?: DevExpress.ui.dxOverlayOptions): JQuery;
dxPopup(options?: DevExpress.ui.dxPopupOptions): JQuery;
dxPopover(options?: DevExpress.ui.dxPopoverOptions): JQuery;
dxTooltip(options?: DevExpress.ui.dxTooltipOptions): JQuery;
dxRadioGroup(options?: DevExpress.ui.dxRadioGroupOptions): JQuery;
dxRangeSlider(options?: DevExpress.ui.dxRangeSliderOptions): JQuery;
dxScrollable(options?: DevExpress.ui.dxScrollableOptions): JQuery;
dxScrollView(options?: DevExpress.ui.dxScrollViewOptions): JQuery;
dxSelectBox(options?: DevExpress.ui.dxSelectBoxOptions): JQuery;
dxSlider(options?: DevExpress.ui.dxSliderOptions): JQuery;
dxTabs(options?: DevExpress.ui.dxTabsOptions): JQuery;
dxTextArea(options?: DevExpress.ui.dxTextAreaOptions): JQuery;
dxTextBox(options?: DevExpress.ui.dxTextBoxOptions): JQuery;
dxToast(options?: DevExpress.ui.dxToastOptions): JQuery;
dxToolbar(options?: DevExpress.ui.dxToolbarOptions): JQuery;
dxDropDownEditor(options?: DevExpress.ui.dxDropDownEditorOptions): JQuery;
dxLoadIndicator(options?: DevExpress.ui.dxLoadIndicatorOptions): JQuery;
dxMultiView(options?: DevExpress.ui.dxMultiViewOptions): JQuery;
dxGallery(options?: DevExpress.ui.dxGalleryOptions): JQuery;
dxDataGrid(options?: DevExpress.ui.dxDataGridOptions): JQuery;
dxMenu(options?: DevExpress.ui.dxMenuOptions): JQuery;
dxContextMenu(options?: DevExpress.ui.dxContextMenuOptions): JQuery;
dxColorPicker(options?: DevExpress.ui.dxColorPickerOptions): JQuery;
dxColorPicker(options?: DevExpress.ui.dxColorPickerOptions): JQuery;
}
+17
View File
@@ -0,0 +1,17 @@
/// <reference path="./empower.d.ts" />
var baseAssert:any;
var fakeFormatter:any;
()=> {
var assert = empower(baseAssert, fakeFormatter);
};
var option:empower.Options = {
modifyMessageOnRethrow: false,
saveContextOnRethrow: false
};
()=> {
var assert = empower(baseAssert, fakeFormatter, option);
};
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for empower
// Project: https://github.com/twada/empower
// Definitions by: vvakame <https://github.com/vvakame>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare function empower(originalAssert:any, formatter:any, options?:empower.Options):any;
declare module empower {
export interface Options {
destructive?: boolean;
modifyMessageOnRethrow?: boolean;
saveContextOnRethrow?: boolean;
patterns?: string[];
}
}
declare module "empower" {
export = empower;
}
@@ -22,12 +22,6 @@ var constructResult1 = new Promise<string>((resolve: (promise: Thenable<string>)
});
promiseString = constructResult1;
//cast test
var castResult = Promise.cast('a string');
promiseString = castResult;
var castResult1 = Promise.cast(Promise.resolve('a string'));
promiseString = castResult1;
//resolve test
var resolveResult = Promise.resolve('a string');
promiseString = resolveResult;
-6
View File
@@ -20,12 +20,6 @@ var constructResult1 = new Promise<string>((resolve:(promise: Thenable<string>)
});
promiseString = constructResult1;
//cast test
var castResult = Promise.cast('a string');
promiseString = castResult;
var castResult1 = Promise.cast(Promise.resolve('a string'));
promiseString = castResult1;
//resolve test
var resolveResult = Promise.resolve('a string');
promiseString = resolveResult;
+1 -11
View File
@@ -118,23 +118,13 @@ declare class Promise<R> implements Thenable<R> {
}
declare module Promise {
/**
* Returns promise (only if promise.constructor == Promise)
*/
function cast<R>(promise: Promise<R>): Promise<R>;
/**
* Make a promise that fulfills to obj.
*/
function cast<R>(object: R): Promise<R>;
/**
* Make a new promise from the thenable.
* A thenable is promise-like in as far as it has a "then" method.
* This also creates a new promise if you pass it a genuine JavaScript promise, making it less efficient for casting than Promise.cast.
*/
function resolve<R>(thenable?: Thenable<R>): Promise<R>;
/**
* Make a promise that fulfills to obj. Same as Promise.cast(obj) in this situation.
* Make a promise that fulfills to obj.
*/
function resolve<R>(object?: R): Promise<R>;
+92
View File
@@ -0,0 +1,92 @@
///<reference path="eventemitter2.d.ts"/>
// import eventemitter2 = require("eventemitter2");
// var EventEmitter2 = eventemitter2.EventEmitter2;
function testConfiguration() {
var foo = new EventEmitter2({
wildcard: true,
delimiter: '::',
newListener: false,
maxListeners: 20
});
var bar = new EventEmitter2({});
var bazz = new EventEmitter2();
}
var server = new EventEmitter2();
function testAddListener() {
server.addListener('data', function (value1: any, value2: any, value3: any) {
console.log('The event was raised!');
});
server.addListener('data', function (value: any) {
console.log('The event was raised!');
});
}
function testOn() {
server.on('data', function (value1: any, value2: any, value3: any) {
console.log('The event was raised!');
});
server.on('data', function (value: any) {
console.log('The event was raised!');
});
}
function testOnAny() {
server.onAny(function (value: any) {
console.log('All events trigger this.');
});
}
function testOffAny() {
server.offAny(function (value: any) {
console.log('The event was raised!');
});
}
function testOnce() {
server.once('get', function (value: any) {
console.log('Ah, we have our first value!');
});
}
function testMany() {
server.many('get', 4, function (value: any) {
console.log('This event will be listened to exactly four times.');
});
}
function testRemoveListener() {
var callback = function (value: any) {
console.log('someone connected!');
};
server.on('get', callback);
server.removeListener('get', callback);
}
function testRemoveAllListeners() {
server.removeAllListeners(["test::event", "another::test::event"]);
server.removeAllListeners("test");
server.removeAllListeners();
}
function testSetMaxListeners() {
server.setMaxListeners(40);
}
function testListeners() {
console.log(server.listeners('get'));
}
function testListenersAny() {
console.log(server.listenersAny()[0]);
}
function testEmit() {
server.emit('foo.bazz');
server.emit(['foo', 'bar']);
}
+146
View File
@@ -0,0 +1,146 @@
// Type definitions for EventEmitter2 v0.14.4
// Project: https://github.com/asyncly/EventEmitter2
// Definitions by: ryiwamoto <https://github.com/ryiwamoto/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module eventemitter2 {
interface Configuration {
/**
* use wildcards
*/
wildcard?: boolean;
/**
* the delimiter used to segment namespaces, defaults to `.`.
*/
delimiter?: string;
/**
* if you want to emit the newListener event set to true.
*/
newListener?: boolean;
/**
* max listeners that can be assigned to an event, default 10.
*/
maxListeners?: number;
}
export class EventEmitter2 {
/**
* @param conf
*/
constructor(conf?: Configuration);
/**
* Adds a listener to the end of the listeners array for the specified event.
* @param event
* @param listener
*/
addListener(event: string, listener: Function): EventEmitter2;
/**
* Adds a listener to the end of the listeners array for the specified event.
* @param event
* @param listener
*/
on(event: string, listener: Function): EventEmitter2;
/**
* Adds a listener that will be fired when any event is emitted.
* @param listener
*/
onAny(listener: Function): EventEmitter2;
/**
* Removes the listener that will be fired when any event is emitted.
* @param listener
*/
offAny(listener: Function): EventEmitter2;
/**
* Adds a one time listener for the event.
* The listener is invoked only the first time the event is fired, after which it is removed.
* @param event
* @param listener
*/
once(event: string, listener: Function): EventEmitter2;
/**
* Adds a listener that will execute n times for the event before being removed.
* The listener is invoked only the first n times the event is fired, after which it is removed.
* @param event
* @param timesToListen
* @param listener
*/
many(event: string, timesToListen: number, listener: Function): EventEmitter2;
/**
* Remove a listener from the listener array for the specified event.
* Caution: changes array indices in the listener array behind the listener.
* @param event
* @param listener
*/
removeListener(event: string, listener: Function): EventEmitter2;
/**
* Remove a listener from the listener array for the specified event.
* Caution: changes array indices in the listener array behind the listener.
* @param event
* @param listener
*/
off(event: string, listener: Function): EventEmitter2;
/**
* Removes all listeners, or those of the specified event.
* @param event
*/
removeAllListeners(event?: string): EventEmitter2;
/**
* Removes all listeners, or those of the specified event.
* @param events
*/
removeAllListeners(events: string[]): EventEmitter2;
/**
* By default EventEmitters will print a warning if more than 10 listeners are added to it.
* This is a useful default which helps finding memory leaks.
* Obviously not all Emitters should be limited to 10. This function allows that to be increased.
* Set to zero for unlimited.
* @param n
*/
setMaxListeners(n: number): void;
/**
* Returns an array of listeners for the specified event. This array can be manipulated, e.g. to remove listeners.
* @param event
*/
listeners(event: string): Function[];
/**
* Returns an array of listeners that are listening for any event that is specified.
* This array can be manipulated, e.g. to remove listeners.
*/
listenersAny(): Function[];
/**
* Execute each of the listeners that may be listening for the specified event name in order with the list of arguments.
* @param event
* @param args
*/
emit(event: string, ...args: string[]): boolean;
/**
* Execute each of the listeners that may be listening for the specified event name in order with the list of arguments.
* @param event
*/
emit(event: string[]): boolean;
}
}
declare module "eventemitter2" {
export = eventemitter2;
}
declare var EventEmitter2: typeof eventemitter2.EventEmitter2;
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for fibers
// Type definitions for form-data
// Project: https://github.com/felixge/node-form-data
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+50
View File
@@ -5,6 +5,56 @@ import Hapi = require('hapi');
// Create a server with a host and port
var server = Hapi.createServer('localhost', 8000);
// Add plugins
var plugin: any = {
register: function (plugin: Object, options: Object, next: Function) {
next();
}
};
plugin.register.attributes = {
name: 'test',
version: '1.0.0'
};
server.pack.register(plugin, (err: Object) => {
if (err) { throw err; }
});
server.pack.register([plugin], (err: Object) => {
if (err) { throw err; }
});
// Add server method
var add = function (a: number, b: number, next: (err: any, result?: any, ttl?: number) => void) {
next(null, a + b);
};
server.method('sum', add, { cache: { expiresIn: 2000 } });
server.methods.sum(4, 5, (err: any, result: any) => {
console.log(result);
});
var addArray = function (array: Array<number>, next: (err: any, result?: any, ttl?: number) => void) {
var sum: number = 0;
array.forEach((item: number) => {
sum += item;
});
next(null, sum);
};
server.method('sumObj', addArray, {
cache: { expiresIn: 2000 },
generateKey: (array: Array<number>) => {
return array.join(',');
}
});
server.methods.sumObj([5, 6], (err: any, result: any) => {
console.log(result);
});
// Add the route
server.route({
method: 'GET',
+3 -2
View File
@@ -103,6 +103,7 @@ declare module Hapi {
export class Pack {
require(name: string, options: {}, callback: Function): void;
register(plugins: any, options?: Object, callback?: Function, state?: Object): void;
}
export interface ServerView {
@@ -278,7 +279,7 @@ declare module Hapi {
export class Server {
app: any;
methods: Array<() => void>;
methods: any;
info: {
port: number;
host?: string;
@@ -335,7 +336,7 @@ declare module Hapi {
};
ext(event: any, method: string, options?: any): void;
method(method: Array<{name: string; fn: () => void; options: any}>): void;
method(name: string, fn: () => void, options: any): void;
method(name: string, fn: Function, options: any): void;
inject(options: any, callback: any): void;
handler(name: string, method: (name: string, options: any) => void): void;
}
+42
View File
@@ -0,0 +1,42 @@
/// <reference path="heatmap.d.ts" />
var baseLayer = L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>',
maxZoom: 18
});
var testData: HeatmapData = {
max: 8,
data: [
{
lat: 24.6408,
lng:46.7728,
count: 3
}, {
lat: 50.75,
lng: -1.55,
count: 1
}
]
};
var config : HeatmapConfiguration = {
radius: 2,
maxOpacity: .8,
scaleRadius: true,
useLocalExtrema: true,
latField: 'lat',
lngField: 'lng',
valueField: 'count'
};
var heatmapLayer = new HeatmapOverlay(config);
var map = new L.Map('map-canvas', {
center: new L.LatLng(25.6586, -80.3568),
zoom: 4,
layers: [baseLayer, heatmapLayer]
});
heatmapLayer.setData(testData);
+134
View File
@@ -0,0 +1,134 @@
// Type definitions for heatmap.js v2.0
// Project: https://github.com/pa7/heatmap.js/
// Definitions by: Yang Guan <https://github.com/lookuptable>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../leaflet/leaflet.d.ts" />
/*
* Configuration object of a heatmap
*/
interface HeatmapConfiguration {
/*
* A background color string in form of hexcode, color name, or rgb(a)
*/
backgroundColor?: string;
/*
* The blur factor that will be applied to all datapoints. The higher the
* blur factor is, the smoother the gradients will be
* Default value: 0.85
*/
blur?: number;
/*
* An object that represents the gradient
*/
gradient?: any;
/*
* The property name of your latitude coordinate in a datapoint
* Default value: 'x'
*/
latField?: string;
/*
* The property name of your longitude coordinate in a datapoint
* Default value: 'y'
*/
lngField?: string;
/*
* The maximal opacity the highest value in the heatmap will have. (will be
* overridden if opacity set)
* Default value: 0.6
*/
maxOpacity?: number;
/*
* The minimum opacity the lowest value in the heatmap will have (will be
* overridden if opacity set)
*/
minOpacity?: number;
/*
* A global opacity for the whole heatmap. This overrides maxOpacity and
* minOpacity if set
*/
opacity?: number;
/*
* The radius each datapoint will have (if not specified on the datapoint
* itself)
*/
radius?: number;
/*
* Indicate whether the heatmap should use a global extrema or a local
* extrema (the maximum and minimum of the currently displayed viewport)
*/
useLocalExtrema?: boolean;
/*
* The property name of the value/weight in a datapoint
*/
valueField: string;
}
/*
* A single data point on a heatmap. The keys are specified by
* HeatmapConfig.latField, HeatmapConfig.lngField and HeatmapConfig.valueField
*/
interface HeatmapDataPoint {
[index: string]: number;
}
/*
* An object representing the set of data points on a heatmap
*/
interface HeatmapData {
/*
* An array of HeatmapDataPoints
*/
data: HeatmapDataPoint[];
/*
* Max value of the valueField
*/
max?: number;
/*
* Min value of the valueField
*/
min?: number;
}
/*
* The overlay layer to be added onto leaflet map
*/
declare class HeatmapOverlay {
/*
* Initialization function
*/
constructor(configuration: HeatmapConfiguration)
/*
* Create DOM elements for an overlay, adding them to map panes and puts
* listeners on relevant map events
*/
onAdd(map: L.Map): void;
/*
* Remove the overlay's elements from the DOM and remove listeners
* previously added by onAdd()
*/
onRemove(map: L.Map): void;
/*
* Initialize a heatmap instance with the given dataset
*/
setData(data: HeatmapData): void;
}
+10 -2
View File
@@ -61,18 +61,26 @@ declare module "htmlparser2" {
}
export class Parser {
constructor(handler: Handler);
constructor(handler: Handler, options?: Options);
/***
* Parses a chunk of data and calls the corresponding callbacks.
* @param input
*/
write(input:string):void;
/***
* alias for backwards compat
*/
parseChunk(input:string):void;
/***
* Parses the end of the buffer and clears the stack, calls onend.
*/
end():void;
/***
* alias for backwards compat
*/
done():void;
/***
@@ -86,4 +94,4 @@ declare module "htmlparser2" {
*/
reset():void;
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for jasmine-matchers v0.2.1 API
// Type definitions for jasmine-matchers v0.2.1
// Project: https://github.com/uxebu/jasmine-matchers
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+24
View File
@@ -0,0 +1,24 @@
/// <reference path="../jquery/jquery.d.ts"/>
/// <reference path="jquery.rowGrid.d.ts"/>
/*
* Test different options
*/
var options = {
minMargin: 10,
maxMargin: 35,
itemSelector: ".item"
};
$(".container").rowGrid(options);
/*
* Test endless scrolling
*/
// append new items
$(".container").append("<div class='item'><img src='http://placehold.it/310x200' /></div>");
// arrange appended items
$(".container").rowGrid("appended");
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for jQuery rowGrid.js plugin (v1.0.2)
// Project: https://github.com/brunjo/rowGrid.js
// Definitions by: Vinayak Garg <https://github.com/vinayak-garg>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
interface JQueryRowGridJSOptions {
minMargin?: number;
maxMargin?: number;
itemSelector: string;
}
interface JQuery {
rowGrid(options?: JQueryRowGridJSOptions): JQuery;
rowGrid(appended: string): JQuery;
}
+1 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for jQueryUI 1.9
// Type definitions for jQuery UI Layout Plug-in
// Project: http://layout.jquery-dev.net/
// Definitions by: Steve Fenton <https://github.com/Steve-Fenton>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -227,4 +227,6 @@ function test_methods() {
maxlength: 5
}
});
var invalidElements: HTMLElement[] = validator.invalidElements();
var validElements: HTMLElement[] = validator.validElements();
}
+2
View File
@@ -197,6 +197,7 @@ interface Validator
* @param template The string to format.
*/
format(template: string, ...arguments: string[]): string;
invalidElements(): HTMLElement[];
/**
* Returns the number of invalid fields.
*/
@@ -220,6 +221,7 @@ interface Validator
showErrors(errors: any): void;
hideErrors(): void;
valid(): boolean;
validElements(): HTMLElement[];
size(): number;
errorMap: ErrorDictionary;
+5
View File
@@ -104,3 +104,8 @@ var treeWithNewCheckboxProperties = $('#treeWithNewCheckboxProperties').jstree({
}
});
var tree = $('a').jstree();
tree.move_node('a', 'b', 0, (node: any, new_par: any, pos: any) => { }, true, true);
tree.copy_node('a', 'b', 0, (node: any, new_par: any, pos: any) => { }, true, true);
+6 -4
View File
@@ -1003,10 +1003,11 @@ interface JSTree extends JQuery {
* @param {mixed} par the new parent
* @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0`
* @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
* @param {Boolean} internal parameter indicating if the parent node has been loaded
* @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
* @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
* @trigger move_node.jstree
*/
move_node: (obj: any, par: any, pos?: any, callback?: any, internal?: boolean) => void;
move_node: (obj: any, par: any, pos?: any, callback?: (node: any, new_par: any, pos: any) => void, is_loaded?: boolean, skip_redraw?: boolean) => void;
/**
* copy a node to a new parent
@@ -1015,10 +1016,11 @@ interface JSTree extends JQuery {
* @param {mixed} par the new parent
* @param {mixed} pos the position to insert at (besides integer values, "first" and "last" are supported, as well as "before" and "after"), defaults to integer `0`
* @param {function} callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position
* @param {Boolean} internal parameter indicating if the parent node has been loaded
* @param {Boolean} is_loaded internal parameter indicating if the parent node has been loaded
* @param {Boolean} skip_redraw internal parameter indicating if the tree should be redrawn
* @trigger model.jstree copy_node.jstree
*/
copy_node: (obj: any, par: any, pos?: any, callback?: any, internal?: boolean) => void;
copy_node: (obj: any, par: any, pos?: any, callback?: (node: any, new_par: any, pos: any) => void, is_loaded?: boolean, skip_redraw?: boolean) => void;
/**
* cut a node (a later call to `paste(obj)` would move the node)
+16 -23
View File
@@ -1,4 +1,3 @@
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path='jszip.d.ts' />
var SEVERITY = {
@@ -10,30 +9,29 @@ var SEVERITY = {
}
function testJSZip() {
var newJszip = new JSZip();
newJszip.file("test.txt", "test string");
newJszip.file("test/test.txt", "test string");
var serializedZip = newJszip.generate({compression: "DEFLATE", type:"base64"});
var serializedZip = newJszip.generate({compression: "DEFLATE", type: "base64"});
newJszip = new JSZip();
newJszip.load(serializedZip, {base64: true, checkCRC32: true});
if(newJszip.file("test.txt").data === "test string") {
if (newJszip.file("test.txt").asText() === "test string") {
log(SEVERITY.INFO, "all ok");
} else {
log(SEVERITY.ERROR, "no matching file found");
}
if(newJszip.file("test/test.txt").data === "test string") {
if (newJszip.file("test/test.txt").asText() === "test string") {
log(SEVERITY.INFO, "all ok");
} else {
log(SEVERITY.ERROR, "no matching file found");
}
var folder = newJszip.folder("test");
if(folder.file("test.txt").data == "test string") {
if(folder.file("test.txt").asText() == "test string") {
log(SEVERITY.INFO, "all ok");
}
else {
@@ -44,7 +42,7 @@ function testJSZip() {
if(folders.length == 1) {
log(SEVERITY.INFO, "all ok");
if(folders[0].options.dir == true) {
if(folders[0].dir == true) {
log(SEVERITY.INFO, "all ok");
}
else {
@@ -57,7 +55,7 @@ function testJSZip() {
var files = newJszip.file(new RegExp("^test"));
if(files.length == 2) {
log(SEVERITY.INFO, "all ok");
if(files[0].data == "test string" && files[1].data == "test string") {
if (files[0].asText() == "test string" && files[1].asText() == "test string") {
log(SEVERITY.INFO, "all ok");
}
else {
@@ -68,11 +66,11 @@ function testJSZip() {
log(SEVERITY.ERROR, "wrong number of files");
}
var filterFiles = newJszip.filter((relativePath: string, file: jszip.JSZipFile) => {
if(file.data == "test string") {
return true;
}
return false;
var filterFiles = newJszip.filter((relativePath: string, file: JSZipObject) => {
if (file.asText() == "test string") {
return true;
}
return false;
});
if(filterFiles.length == 2) {
@@ -84,11 +82,11 @@ function testJSZip() {
newJszip.remove("test/test.txt");
filterFiles = newJszip.filter((relativePath: string, file: jszip.JSZipFile) => {
if(file.data == "test string") {
return true;
}
return false;
filterFiles = newJszip.filter((relativePath: string, file: JSZipObject) => {
if (file.asText() == "test string") {
return true;
}
return false;
});
if(filterFiles.length == 1) {
@@ -97,11 +95,6 @@ function testJSZip() {
else {
log(SEVERITY.ERROR, "wrong number of files");
}
log(SEVERITY.INFO, newJszip.crc32("Test"));
log(SEVERITY.INFO, newJszip.utf8encode("Test"));
log(SEVERITY.INFO, newJszip.utf8decode("Test"));
newJszip.clone();
}
function log(severity:number, message: any) {
+145 -152
View File
@@ -3,181 +3,174 @@
// Definitions by: mzeiher <https://github.com/mzeiher>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module jszip {
export interface JSZip {
/**
* Get a file from the archive
*
* @param path {string} relative path to file
*
* @return {JSZipFile} file matching path, null if no file found
*/
file(path: string): JSZipFile;
interface JSZip {
/**
* Get a file from the archive
*
* @param Path relative path to file
* @return File matching path, null if no file found
*/
file(path: string): JSZipObject;
/**
* Get files matching a RegExp from archive
*
* @param path {RegExp} RegExp to match
*
* @return {JSZipFile[]} return all matching files or an empty array
*/
file(path: RegExp): JSZipFile[];
/**
* Get files matching a RegExp from archive
*
* @param path RegExp to match
* @return Return all matching files or an empty array
*/
file(path: RegExp): JSZipObject[];
/**
* Add a file to the archive
*
* @param path {string} relative path to file
* @param content {any} content of the file
* @param options {JSZipOptions} optional information about the file
*
* @return {JSZip} JSZip object
*/
file(path: string, content: any, options?: JSZipOptions): JSZip;
/**
* Add a file to the archive
*
* @param path Relative path to file
* @param content Content of the file
* @param options Optional information about the file
* @return JSZip object
*/
file(path: string, data: any, options?: JSZipFileOptions): JSZip;
/**
* Return an new JSZip instance with the given folder as root
*
* @param name {string} name of the folder
*
* @return {JSZip} new JSZip object with the given folder as root or null
*/
folder(name: string): JSZip;
/**
* Return an new JSZip instance with the given folder as root
*
* @param name Name of the folder
* @return New JSZip object with the given folder as root or null
*/
folder(name: string): JSZip;
/**
* Returns new JSZip instances with the matching folders as root
*
* @param name {RegExp} RegExp to match
*
* @return {JSZipFile[]} new array of JSZipFile objects which match the RegExp
*/
folder(name: RegExp): JSZipFile[];
/**
* Returns new JSZip instances with the matching folders as root
*
* @param name RegExp to match
* @return New array of JSZipFile objects which match the RegExp
*/
folder(name: RegExp): JSZipObject[];
/**
* Removes the file or folder from the archive
*
* @param path {string} relative path of file or folder
*
* @return {JSZip} returns the JSZip instance
*/
remove(path: string): JSZip;
/**
* Get all files wchich match the given filter function
*
* @param predicate Filter function
* @return Array of matched elements
*/
filter(predicate: (relativePath: string, file: JSZipObject) => boolean): JSZipObject[];
/**
* Generates a new archive
*
* @param options {JSZipGeneratorOptions} optional options for the generator
*
* @return {any} the serialized archive
*/
generate(options?: JSZipGeneratorOptions): any;
/**
* Removes the file or folder from the archive
*
* @param path Relative path of file or folder
* @return Returns the JSZip instance
*/
remove(path: string): JSZip;
/**
* Deserialize zip file
*
* @param data {any} serialized zip file
* @param options {JSZipOptions} options for deserializing
*
* @return {JSZip} returns the JSZip instance
*/
load(data: any, options: JSZipOptions): JSZip;
/**
* Generates a new archive
*
* @param options Optional options for the generator
* @return The serialized archive
*/
generate(options?: JSZipGeneratorOptions): any;
/**
* Get all files wchich match the given filter function
*
* @param {function} filter function
*
* @return {JSZipFile[]} array of matched elements
*/
filter(predicate: (relativePath: string, file: JSZipFile) => boolean): JSZipFile[];
/**
* Deserialize zip file
*
* @param data Serialized zip file
* @param options Options for deserializing
* @return Returns the JSZip instance
*/
load(data: any, options: JSZipLoadOptions): JSZip;
}
/**
* Calculate crc32 of given string
*
* @param data {string} string to calculate crc32 from
* @param crc {number} optional: initializer for crc calc
*
* @return {number} calculated crc32 number
*/
crc32(data: string, crc?: number): number;
interface JSZipObject {
name: string;
dir: boolean;
date: Date;
comment: string;
options: JSZipObjectOptions;
/**
* Clone JSSZip instance
*
* return {JSZip} cloned instsance
*/
clone(): JSZip;
asText(): string;
asBinary(): string;
asArrayBuffer(): ArrayBuffer;
asUint8Array(): Uint8Array;
//asNodeBuffer(): Buffer;
}
/**
* UTF8 encode a string
*
* @param data {string} string to encode
*/
utf8encode(data: string): string;
interface JSZipFileOptions {
base64?: boolean;
binary?: boolean;
date?: Date;
compression?: string;
comment?: string;
optimizedBinaryString?: boolean;
createFolders?: boolean;
}
/**
* UTF8 decode a string
*
* @param data {string} string to decode
*/
utf8decode(data: string): string;
interface JSZipObjectOptions {
/** deprecated */
base64: boolean;
/** deprecated */
binary: boolean;
/** deprecated */
dir: boolean;
/** deprecated */
date: Date;
compression: string;
}
}
interface JSZipGeneratorOptions {
/** deprecated */
base64?: boolean;
/** DEFLATE or STORE */
compression?: string;
/** base64 (default), string, uint8array, blob */
type?: string;
comment?: string;
}
export interface JSZipSupport {
arraybuffer: boolean;
uint8array: boolean;
blob: boolean;
}
interface JSZipLoadOptions {
base64?: boolean;
checkCRC32?: boolean;
optimizedBinaryString?: boolean;
createFolders?: boolean;
}
export interface JSZipGeneratorOptions {
base64?: boolean; //deprecated
compression: string; //DEFLATE or STORE
type: string; //base64 (default), string, uint8array, blob
}
export interface JSZipOptions {
base64: boolean;
checkCRC32: boolean;
}
export interface JSZipFile {
name: string;
data: any;
options: JSZipFileOptions;
asText(): string;
asBinary(): any;
asArrayBuffer(): ArrayBuffer;
asUint8Array(): Uint8Array;
}
export interface JSZipFileOptions {
base64: boolean;
binary: boolean;
dir: boolean;
date: Date;
}
export interface JSZipBase64 {
}
interface JSZipSupport {
arraybuffer: boolean;
uint8array: boolean;
blob: boolean;
nodebuffer: boolean;
}
declare var JSZip: {
/**
* Create JSZip instance
*/
(): JSZip;
/**
* Create JSZip instance
* If no parameters given an empty zip archive will be created
*
* @param data {any} serialized zip archive
* @param options {JSZipOptions} description of the serialized zip archive
* @param data Serialized zip archive
* @param options Description of the serialized zip archive
*/
new(data?: any, options?: jszip.JSZipOptions): jszip.JSZip;
(data: any, options?: JSZipLoadOptions): JSZip;
prototype: jszip.JSZip;
support : jszip.JSZipSupport;
/**
* Create JSZip instance
*/
new (): JSZip;
/**
* Create JSZip instance
* If no parameters given an empty zip archive will be created
*
* @param data Serialized zip archive
* @param options Description of the serialized zip archive
*/
new (data: any, options?: JSZipLoadOptions): JSZip;
prototype: JSZip;
support: JSZipSupport;
}
declare var JSZipBase64: {
encode(input: string, utf8?: any): string;
decode(input: string, utf8?: any): string;
prototype: jszip.JSZipBase64;
}
declare module "jszip" {
export = JSZip;
}
@@ -0,0 +1,23 @@
/// <reference path="knockout-secure-binding.d.ts" />
// knockout-secure-binding
// The MIT License(MIT)
// Copyright(c) 2013 Brian M Hunt
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import ksp = require('knockout-secure-binding');
function testt(): void {
// https://github.com/brianmhunt/knockout-secure-binding
var options = {
attribute: "data-bind", // default "data-sbind"
globals: window, // default {}
bindings: ko.bindingHandlers, // default ko.bindingHandlers
noVirtualElements: false // default true
};
ko.bindingProvider.instance = new ko.secureBindingsProvider(options);
ko.bindingProvider.instance = new ksp(options);
}
+31
View File
@@ -0,0 +1,31 @@
// Type definitions for knockout-secure-binding
// Project: https://github.com/brianmhunt/knockout-secure-binding
// Definitions by: Pine Mizune <https://github.com/pine613>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../knockout/knockout.d.ts" />
interface KnockoutSecureBindingOptions {
attribute?: string;
globals?: any;
bindings?: KnockoutBindingHandlers;
noVirtualElements?: boolean;
}
interface KnockoutSecureBindingProvider extends KnockoutBindingProvider {
new (options?: KnockoutSecureBindingOptions): KnockoutBindingProvider;
}
interface KnockoutStatic {
secureBindingsProvider: {
new (options?: KnockoutSecureBindingOptions): KnockoutBindingProvider;
};
}
declare module "knockout-secure-binding" {
var klass: {
new (options?: KnockoutSecureBindingOptions): KnockoutBindingProvider;
};
export = klass;
}

Some files were not shown because too many files have changed in this diff Show More