Merge pull request #1 from borisyankov/master

This commit is contained in:
laszlojakab
2015-02-24 09:22:32 +01:00
970 changed files with 121335 additions and 832083 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
+795 -394
View File
File diff suppressed because it is too large Load Diff
+11
View File
@@ -0,0 +1,11 @@
/// <reference path="FileSaver.d.ts" />
/**
* @summary Test for "saveAs" function.
*/
function testSaveAs() {
var data: Blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
var filename: string = 'hello world.txt';
saveAs(data, filename);
}
+1
View File
@@ -0,0 +1 @@
--noImplicitAny
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for FileSaver.js
// Project: https://github.com/eligrey/FileSaver.js/
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/**
* @summary Interface for "saveAs" function.
* @author Cyril Schumacher
* @version 1.0
*/
interface FileSaver {
(
/**
* @summary Data.
* @type {Blob}
*/
data: Blob,
/**
* @summary File name.
* @type {DOMString}
*/
filename: string
): void
}
declare var saveAs: FileSaver;
+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;
}
+2 -2
View File
@@ -30,7 +30,7 @@ Please see the [contribution guide](http://definitelytyped.org/guides/contributi
## Requested definitions
Here is an updated list of [definitions people have requested](https://github.com/borisyankov/DefinitelyTyped/issues?labels=Definition%3ARequest).
Here is are the [currently requested definitions](https://github.com/borisyankov/DefinitelyTyped/labels/Definition%3ARequest).
## Licence
@@ -38,4 +38,4 @@ This project is licensed under the MIT license.
Copyrights on the definition files are respective of each contributor listed at the beginning of each definition file.
[![Analytics](https://ga-beacon.appspot.com/UA-47495295-4/borisyankov/DefinitelyTyped)](https://github.com/igrigorik/ga-beacon)
[![Analytics](https://ga-beacon.appspot.com/UA-47495295-4/borisyankov/DefinitelyTyped)](https://github.com/igrigorik/ga-beacon)
-1
View File
@@ -1 +0,0 @@
require('definition-tester');
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
#!/usr/bin/env node
require('./tsc.js')
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
#!/usr/bin/env node
require('./tsc.js')
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
#!/usr/bin/env node
require('./tsc.js')
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
#!/usr/bin/env node
require('./tsc.js')
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
#!/usr/bin/env node
require('./tsc.js')
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -1,2 +0,0 @@
#!/usr/bin/env node
require('./tsc.js')
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+36
View File
@@ -0,0 +1,36 @@
/// <reference path="../jquery/jquery.d.ts"/>
/// <reference path="acc-wizard.d.ts" />
/**
* @summary Test for "accwizard" without options.
*/
function testBasic() {
$('#test').accwizard();
}
/**
* @summary Test for "accwizard" with options.
*/
function testWithOptions() {
var options: AccWizardOptions = {
addButtons: true,
sidebar: '.acc-wizard-sidebar',
activeClass: 'acc-wizard-active',
completedClass: 'acc-wizard-completed',
todoClass: 'acc-wizard-todo',
stepClass: 'acc-wizard-step',
nextText: 'Next Step',
backText: 'Go Back',
nextType: 'submit',
backType: 'reset',
nextClasses: 'btn btn-primary',
backClasses: 'btn',
autoScrolling: true,
onNext: function() {},
onBack: function() {},
onInit: function() {},
onDestroy: function() {}
};
$('#test').accwizard(options);
}
+101
View File
@@ -0,0 +1,101 @@
// Type definitions for acc-wizard
// Project: https://github.com/sathomas/acc-wizard
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface AccWizardOptions {
/**
* @summary Add next/prev buttons to panels.
* @type {boolean}
*/
addButtons: boolean;
/**
* @summary Selector for task sidebar.
* @type {string}
*/
sidebar: string;
/**
* @summary Class to indicate the active task in sidebar.
* @type {string}
*/
activeClass: string;
/**
* @summary Class to indicate task is complete.
* @type {string}
*/
completedClass: string;
/**
* @summary Class to indicate task is still pending.
* @type {string}
*/
todoClass: string;
/**
* @summary Class for step buttons within panels.
* @type {string}
*/
stepClass: string;
/**
* @summary Text for next button.
* @type {string}
*/
nextText: string;
/**
* @summary Text for back button
* @type {string}
*/
backType: string;
/**
* @summary Class(es) for next button.
* @type {string}
*/
nextClasses: string;
/**
* @summary Class(es) for back button.
* @type {string}
*/
backClasses: string;
/**
* @summary Auto-scrolling.
* @type {boolean}
*/
autoScrolling: boolean;
/**
* @summary Function to call on next step.
*/
onNext: Function;
/**
* @summary Function to call on back up.
*/
onBack: Function;
/**
* @summary A chance to hook initialization.
*/
onInit: Function;
/**
* @summary A chance to hook destruction.
*/
onDestroy: Function;
}
/**
* @summary Interface for "acc-wizard" JQuery plugin.
* @author Cyril Schumacher
* @version 1.0
*/
interface JQuery {
accwizard(options?: AccWizardOptions): void;
}
+1
View File
@@ -0,0 +1 @@
--noImplicitAny
+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;
}
+80
View File
@@ -0,0 +1,80 @@
/// <reference path="./amqp-rpc.d.ts" />
import amqp_rpc = require('amqp-rpc');
var rpc = amqp_rpc.factory();
interface Name {
name?: string;
}
rpc.on<number>('inc', function (param, cb) {
var prevVal = param;
var nextVal = param + 2;
cb(++param, prevVal, nextVal);
});
rpc.on<Name>('say.*', function (param, cb, inf) {
var arr = inf.cmd.split('.');
var name = (param && param.name) ? param.name : 'world';
cb(arr[1] + ' ' + name + '!');
});
rpc.on('withoutCB', function (param, cb, inf) {
if (cb) {
cb('please run function without cb parameter')
}
else {
console.log('this is function withoutCB');
}
});
rpc.call<number>('inc', 5, function (param1, param2, param3) {
console.log(param1, param2, param3);
});
rpc.call<Name>('say.Hello', { name: 'John' }, function (msg) {
console.log('results of say.Hello:', msg); //output: Hello John!
});
rpc.call<any>('withoutCB', {}, function (msg) {
console.log('withoutCB results:', msg); //output: please run function without cb parameter
});
rpc.call<any>('withoutCB', {}); //output message on server side console
import os = require('os');
interface State {
type: string;
}
var counter = 0;
rpc.onBroadcast<State>('getWorkerStat', function (params, cb) {
if (params && params.type == 'fullStat') {
cb(null, {
pid: process.pid,
hostname: os.hostname(),
uptime: process.uptime(),
counter: counter++
});
}
else {
cb(null, { counter: counter++ })
}
});
var all_stats: any = {};
rpc.callBroadcast<State>(
'getWorkerStat',
{ type: 'fullStat' }, //request parameters
{ //call options
ttl: 1000, //wait response time (1 seconds), after run onComplete
onResponse: function (err: any, stat: any) { //callback on each worker response
all_stats[stat.hostname + ':' + stat.pid] = stat;
},
onComplete: function () { //callback on ttl expired
console.log('----------------------- WORKER STATISTICS ----------------------------------------');
for (var worker in all_stats) {
var s: any = all_stats[worker];
console.log(worker, '\tuptime=', s.uptime.toFixed(2) + ' seconds', '\tcounter=', s.counter);
}
}
});
+72
View File
@@ -0,0 +1,72 @@
// Type definitions for amqp-rpc v0.0.8
// Project: https://github.com/demchenkoe/node-amqp-rpc/
// Definitions by: Wonshik Kim <https://github.com/wokim/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "amqp-rpc" {
export interface Options {
connection?: any;
url?: string;
exchangeInstance?: any;
exchange?: string;
exchange_options?: {
exclusive?: boolean;
autoDelete?: boolean;
};
ipml_options?: {
defaultExchangeName?: string;
}
conn_options?: any;
}
export interface CallOptions {
correlationId?: string;
autoDeleteCallback?: any;
}
export interface HandlerOptions {
queueName?: string;
durable?: boolean;
exclusive?: boolean;
autoDelete?: boolean;
}
export interface BroadcastOptions {
ttl?: number;
onResponse?: any;
context?: any;
onComplete?: any;
}
export interface CommandInfo {
cmd?: string;
exchange?: string;
contentType?: string;
size?: number;
}
export interface Callback {
(...args: any[]): void;
}
export interface CallbackWithError {
(err: any, ...args: any[]): void;
}
export function factory(opt?: Options): amqpRPC;
export class amqpRPC {
constructor(opt?: Options);
generateQueueName(type: string): string;
disconnect(): void;
call<T>(cmd: string, params: T, cb?: Callback, context?: any, options?: CallOptions): string;
on<T>(cmd: string, cb: (param?: T, cb?: Callback, info?: CommandInfo) => void, context?: any, options?: HandlerOptions): boolean;
off(cmd: string): boolean;
callBroadcast<T>(cmd: string, params: T, options?: BroadcastOptions): void;
onBroadcast<T>(cmd: string, cb?: (params?: T, cb?: CallbackWithError) => void, context?: any, options?: any): boolean;
offBroadcast(cmd: string): boolean;
}
}
@@ -0,0 +1,47 @@
/// <reference path="angular-file-upload.d.ts" />
module controllers {
"use strict";
var controllerId = "upload";
class Upload {
static $inject = ["$upload"];
constructor(
private $upload: ng.angularFileUpload.IUploadService
) {
}
onFileSelect($files: File[]) {
//$files: an array of files selected, each file has name, size, and type.
var uploads: ng.IPromise<any>[] = [];
for (var i = 0; i < $files.length; i++) {
var file = $files[i];
uploads.push(this.$upload.upload<any>({
url: "/api/upload",
method: "POST",
data: {
extraData: {
fileName: file.name, test: "anything"
}
},
file: file
})
.progress((evt: any) => {
console.log('progress');
})
.then(success => {
// file is uploaded successfully
console.log(success.data);
})
.catch(err => {
console.error(err);
}));
}
}
}
angular.module("app").controller(controllerId, Upload);
}
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for Angular File Upload 1.6.7
// Project: https://github.com/danialfarid/angular-file-upload
// Definitions by: John Reilly <https://github.com/johnnyreilly>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ng.angularFileUpload {
interface IUploadService {
http<T>(config: ng.IRequestConfig): IUploadPromise<T>;
upload<T>(config: IFileUploadConfig): IUploadPromise<T>;
}
interface IUploadPromise<T> extends IHttpPromise<T> {
progress(callback: IHttpPromiseCallback<T>): IUploadPromise<T>;
}
interface IFileUploadConfig extends ng.IRequestConfig {
file: File;
fileName?: string;
}
}
+13 -3
View File
@@ -1,6 +1,6 @@
// Type definitions for angular-hotkeys
// Project: https://github.com/chieffancypants/angular-hotkeys
// Definitions by: Jason Zhao <https://github.com/jlz27>
// Definitions by: Jason Zhao <https://github.com/jlz27>, Stefan Steinhart <https://github.com/reppners>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
@@ -9,21 +9,28 @@ declare module ng.hotkeys {
interface HotkeysProvider {
template: string;
templateTitle:string;
includeCheatSheet: boolean;
cheatSheetHotkey: string;
cheatSheetDescription: string;
add(combo: string, description: string, callback: (event: Event, hotkeys: ng.hotkeys.Hotkey) => void): void;
add(combo: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array<string>, persistent?: boolean): ng.hotkeys.Hotkey;
add(hotkeyObj: ng.hotkeys.Hotkey): void;
add(combo: string, description: string, callback: (event: Event, hotkey?: Hotkey) => void, action?: string, allowIn?: Array<string>, persistent?: boolean): ng.hotkeys.Hotkey;
add(hotkeyObj: ng.hotkeys.Hotkey): ng.hotkeys.Hotkey;
bindTo(scope : ng.IScope): ng.hotkeys.HotkeysProviderChained;
del(combo: string): void;
del(hotkeyObj: ng.hotkeys.Hotkey): void;
get(combo: string): ng.hotkeys.Hotkey;
toggleCheatSheet(): void;
purgeHotkeys(): void;
}
interface HotkeysProviderChained {
@@ -36,5 +43,8 @@ declare module ng.hotkeys {
combo: string;
description?: string;
callback: (event: Event, hotkey: ng.hotkeys.Hotkey) => void;
action?: string;
allowIn?: Array<string>;
persistent?: boolean;
}
}
@@ -0,0 +1,14 @@
/// <reference path="./angular-http-auth.d.ts" />
(function () {
'use strict';
angular.module('login', ['http-auth-interceptor'])
.controller('LoginController', ($scope:any, $http:any, authService:ng.httpAuth.IAuthService) => {
$scope.submit = () => {
$http.post('auth/login').success(() => {
authService.loginConfirmed();
});
}
});
})();
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for angular-http-auth 1.2.1
// Project: https://github.com/witoldsz/angular-http-auth
// Definitions by: vvakame <https://github.com/vvakame>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ng.httpAuth {
interface IAuthService {
loginConfirmed(data?:any, configUpdater?:Function):void;
loginCancelled(data?:any, reason?:any):void;
}
interface IHttpBuffer {
append(config:ng.IRequestConfig, deferred:{resolve(data:any):void; reject(data:any):void;}):void;
rejectAll(reason?:any):void;
retryAll(updater?:Function):void;
}
}
@@ -0,0 +1,75 @@
/// <reference path='../angularjs/angular.d.ts' />
/// <reference path='angular-local-storage.d.ts' />
interface TestScope extends ng.IScope {
submit: (key: string, value: string) => boolean;
getItem: (key: string) => string;
removeItem: (key: string) => boolean;
clearNumbers: () => boolean;
clearAll: () => boolean;
unbind: Function;
update: (val: string) => void;
property: string;
}
module ng.local.storage.tests {
export class TestController {
constructor($scope: TestScope, localStorageService: ng.local.storage.ILocalStorageService<string>) {
// isSupported
if (localStorageService.isSupported) {
// do something
}
// getStorageType
var storageType: string = localStorageService.getStorageType();
// set
$scope.submit = (key, value) => {
return localStorageService.set(key, value);
};
// get
$scope.getItem = (key) => {
return localStorageService.get(key);
};
// remove
$scope.removeItem = (key) => {
return localStorageService.remove(key);
};
// clearAll(regexp)
$scope.clearNumbers = () => {
return localStorageService.clearAll(/^\d+$/);
};
// clearAll
$scope.clearAll = () => {
return localStorageService.clearAll();
};
// keys
var lsKeys = localStorageService.keys();
// bind
localStorageService.set('property', 'oldValue');
$scope.unbind = localStorageService.bind($scope, 'property');
// deriveKey
console.log(localStorageService.deriveKey('property')); // ls.property
// length
var lsLength: number = localStorageService.length();
}
}
}
var app = angular.module('angular-local-storage-tests', ['LocalStorageModule']);
app.config(function (localStorageServiceProvider: ng.local.storage.ILocalStorageServiceProvider) {
localStorageServiceProvider
.setPrefix('myApp')
.setStorageType('sessionStorage')
.setNotify(true, true);
});
app.controller('TestController', ng.local.storage.tests.TestController);
+149
View File
@@ -0,0 +1,149 @@
// Type definitions for angular-local-storage v0.1.5
// Project: https://github.com/grevory/angular-local-storage
// Definitions by: Ken Fukuyama <https://github.com/kenfdev>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../angularjs/angular.d.ts' />
declare module ng.local.storage {
interface ILocalStorageServiceProvider extends IServiceProvider {
/**
* Setter for the prefix
* You should set a prefix to avoid overwriting any local storage variables from the rest of your app
* e.g. localStorageServiceProvider.setPrefix('youAppName');
* With provider you can use config as this:
* myApp.config(function (localStorageServiceProvider) {
* localStorageServiceProvider.prefix = 'yourAppName';
* });
* @param prefix default: ls.<your-key>
*/
setPrefix(prefix: string):ILocalStorageServiceProvider;
/**
* Setter for the storageType
* @param storageType localstorage or sessionStorage. default: localStorage
*/
setStorageType(storageType: string):ILocalStorageServiceProvider;
/**
* Setter for cookie config
* @param exp number of days before cookies expire (0 = does not expire). default: 30
* @param path the web path the cookie represents. default: '/'
*/
setStorageCookie(exp: number, path: string):ILocalStorageServiceProvider;
/**
* Set the cookie domain, since this runs inside a the config() block, only providers and constants can be injected. As a result, $location service can't be used here, use a hardcoded string or window.location.
* No default value
*/
setStorageCookieDomain(domain: string):ILocalStorageServiceProvider;
/**
* Send signals for each of the following actions:
* @param setItem default: true
* @param removeItem default: false
*/
setNotify(setItem: boolean, removeItem: boolean):ILocalStorageServiceProvider;
}
interface ICookie {
/**
* Checks if cookies are enabled in the browser.
* Returns: Boolean
*/
isSupported:boolean;
/**
* Directly adds a value to cookies.
* Note: Typically used as a fallback if local storage is not supported.
* Returns: Boolean
* @param key
* @param val
*/
set(key:string, val:string):boolean;
/**
* Directly get a value from a cookie.
* Returns: value from local storage
* @param key
*/
get(key:string):string;
/**
* Remove directly value from a cookie.
* Returns: Boolean
* @param key
*/
remove(key:string):boolean;
/**
* Remove all data for this app from cookie.
*/
clearAll():any;
}
interface ILocalStorageService<T> {
/**
* Checks if the browser support the current storage type(e.g: localStorage, sessionStorage).
* Returns: Boolean
*/
isSupported:boolean;
/**
* Returns: String
*/
getStorageType():string;
/**
* Directly adds a value to local storage.
* If local storage is not supported, use cookies instead.
* Returns: Boolean
* @param key
* @param value
*/
set(key: string, value: T): boolean;
/**
* Directly get a value from local storage.
* If local storage is not supported, use cookies instead.
* Returns: value from local storage
* @param key
*/
get(key: string): T;
/**
* Return array of keys for local storage, ignore keys that not owned.
* Returns: value from local storage
*/
keys(): string[];
/**
* Remove an item from local storage by key.
* If local storage is not supported, use cookies instead.
* Returns: Boolean
* @param key
*/
remove(key: string): boolean;
/**
* Remove all data for this app from local storage.
* If local storage is not supported, use cookies instead.
* Note: Optionally takes a regular expression string and removes matching.
* Returns: Boolean
* @param regularExpression
*/
clearAll(regularExpression?:RegExp):boolean;
/**
* Bind $scope key to localStorageService.
* Usage: localStorageService.bind(scope, property, value[optional], key[optional])
* Returns: deregistration function for this listener.
* @param scope
* @param property
* @param value optional
* @param key The corresponding key used in local storage
*/
bind(scope:ng.IScope, property: string, value?: any, key?: string): Function;
/**
* Return the derive key
* Returns String
* @param key
*/
deriveKey(key:string):string;
/**
* Return localStorageService.length, ignore keys that not owned.
* Returns Number
*/
length():number;
/**
* Deal with browser's cookies directly.
*/
cookie:ICookie;
}
}
+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;
}
}
+270 -98
View File
@@ -1,11 +1,7 @@
/// <reference path="angular-protractor.d.ts" />
function TestWebDriverExports() {
var abstractBuilder: protractor.AbstractBuilder = new protractor.AbstractBuilder();
var baseAbstractBuilder: webdriver.AbstractBuilder = abstractBuilder;
var button: protractor.Button = new protractor.Button();
var baseButton: webdriver.Button = button;
var button: number = protractor.Button.LEFT;
var key: string = protractor.Key.ADD;
var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1);
@@ -18,12 +14,6 @@ function TestWebDriverExports() {
var action: protractor.ActionSequence = new protractor.ActionSequence(driver);
var baseAction: webdriver.ActionSequence = action;
var alert: protractor.Alert = new protractor.Alert(driver, 'Message');
var baseAlert: webdriver.Alert = alert;
var unhandledAlertError: protractor.UnhandledAlertError = new protractor.UnhandledAlertError('Message', alert);
var baseUnhandledAlertError: webdriver.UnhandledAlertError = unhandledAlertError;
var browser: string = protractor.Browser.ANDROID;
var builder: protractor.Builder = new protractor.Builder();
@@ -42,89 +32,168 @@ function TestWebDriverExports() {
var eventEmitter: protractor.EventEmitter = new protractor.EventEmitter();
var baseEventEmitter: webdriver.EventEmitter = eventEmitter;
var firefoxDomExecutor: protractor.FirefoxDomExecutor = new protractor.FirefoxDomExecutor();
var baseFirefoxDomExecutor: webdriver.FirefoxDomExecutor = firefoxDomExecutor;
var webElement: protractor.WebElement = new protractor.WebElement(driver, new protractor.promise.Promise());
var baseWebElement: webdriver.WebElement = webElement;
var locator: protractor.Locator = new protractor.Locator('id', 'ABC');
var baseLocator: webdriver.Locator = locator;
var locator: webdriver.Locator = by.id('abc');
var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android());
var baseSession: webdriver.Session = session;
locator = protractor.By.name('name');
// logging module
var driver: protractor.WebDriver = new protractor.WebDriver(session, <webdriver.CommandExecutor><any>{});
driver = new protractor.WebDriver(session, <webdriver.CommandExecutor><any>{}, new webdriver.promise.ControlFlow());
var baseDriver: webdriver.WebDriver = driver;
var levelName: string = protractor.logging.LevelName.ALL;
var webElement: protractor.WebElement = new protractor.WebElement(driver, { ELEMENT: 'abc' });
var baseWebElement: webdriver.WebElement = webElement;
var webElementPromise: protractor.WebElementPromise = new protractor.WebElementPromise(driver, { ELEMENT: 'abc' });
var baseWebElementPromise: webdriver.WebElementPromise = webElementPromise;
}
function TestWebDriverErrorModule() {
var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
var baseError: webdriver.error.Error = error;
}
function TestWebDriverLoggingModule() {
var levelName: string = protractor.logging.Level.ALL.name;
var loggingType: string = protractor.logging.Type.CLIENT;
var level: webdriver.logging.Level = protractor.logging.Level.ALL;
var level: webdriver.logging.ILevel = protractor.logging.Level.ALL;
var entry: protractor.logging.Entry = new protractor.logging.Entry(protractor.logging.Level.ALL, 'Message');
var baseEntry: webdriver.logging.Entry = entry;
level = protractor.logging.getLevel('DEBUG');
protractor.logging.Preferences = { a: 123 };
var prefs: protractor.logging.Preferences = new protractor.logging.Preferences();
}
// promise module
function TestWebDriverPromiseModule() {
var cancelError: protractor.promise.CancellationError = new protractor.promise.CancellationError();
cancelError = new protractor.promise.CancellationError('message');
var baseCancelError: webdriver.promise.CancellationError = cancelError;
var promise: protractor.promise.Promise = new protractor.promise.Promise();
var basePromise: webdriver.promise.Promise = promise;
var thenable: protractor.promise.Thenable<any> = new protractor.promise.Thenable();
var baseThenable: webdriver.promise.Thenable<any> = thenable;
var deferred: protractor.promise.Deferred = new protractor.promise.Deferred();
var baseDeferred: webdriver.promise.Deferred = deferred;
var promise: protractor.promise.Promise<any> = new protractor.promise.Promise();
var basePromise: webdriver.promise.Promise<any> = promise;
var deferred: protractor.promise.Deferred<any> = new protractor.promise.Deferred();
var baseDeferred: webdriver.promise.Deferred<any> = deferred;
var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow();
var baseFlow: webdriver.promise.ControlFlow = flow;
protractor.promise.asap(promise, function(value: any){ return true; });
protractor.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; });
var arrayPromise: protractor.promise.Promise<any[]> = protractor.promise.all([new protractor.promise.Promise<number>(), new protractor.promise.Promise<string>()]);
promise = protractor.promise.checkedNodeCall(function(err: any, value: any) { return 123; });
protractor.promise.asap(promise, function (value: any) { return true; });
protractor.promise.asap(promise, function (value: any) { }, function (err: any) { return 'ABC'; });
promise = protractor.promise.checkedNodeCall(function (err: any, value: any) { return 123; });
promise = protractor.promise.consume(function () {
return 5;
});
promise = protractor.promise.consume(function () {
return 5;
}, this);
promise = protractor.promise.consume(function () {
return 5;
}, this, 1, 2, 3);
flow = protractor.promise.controlFlow();
promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
promise = protractor.promise.createFlow(function (newFlow: webdriver.promise.ControlFlow) { });
deferred = protractor.promise.defer(function() {});
deferred = protractor.promise.defer(function(reason?: any) {});
deferred = protractor.promise.defer();
promise = protractor.promise.delayed(123);
var numbersPromise: protractor.promise.Promise<number[]> = protractor.promise.filter([1, 2, 3], function (el: number, index: number, arr: number[]) {
return true;
});
numbersPromise = protractor.promise.filter([1, 2, 3], function (el: number, index: number, arr: number[]) {
return true;
}, this);
numbersPromise = protractor.promise.filter(numbersPromise, function (el: number, index: number, arr: number[]) {
return true;
});
numbersPromise = protractor.promise.filter(numbersPromise, function (el: number, index: number, arr: number[]) {
return true;
}, this);
numbersPromise = protractor.promise.map([1, 2, 3], function (el: number, index: number, arr: number[]) {
return true;
});
numbersPromise = protractor.promise.map([1, 2, 3], function (el: number, index: number, arr: number[]) {
return true;
}, this);
numbersPromise = protractor.promise.map(numbersPromise, function (el: number, index: number, arr: number[]) {
return true;
});
numbersPromise = protractor.promise.map(numbersPromise, function (el: number, index: number, arr: number[]) {
return true;
}, this);
promise = protractor.promise.fulfilled();
promise = protractor.promise.fulfilled({a: 123});
promise = protractor.promise.fulfilled({ a: 123 });
promise = protractor.promise.fullyResolved({a: 123});
promise = protractor.promise.fullyResolved({ a: 123 });
var isPromise: boolean = protractor.promise.isPromise('ABC');
var bool: boolean = protractor.promise.isGenerator(function () { });
var bool: boolean = protractor.promise.isPromise('ABC');
promise = protractor.promise.rejected({a: 123});
promise = protractor.promise.rejected({ a: 123 });
protractor.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
promise = protractor.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; });
promise = protractor.promise.when(promise, function (value: any) { return 123; }, function (err: Error) { return 123; });
}
// error module
function TestWebDriverStacktraceModule() {
var bool: boolean = protractor.stacktrace.BROWSER_SUPPORTED;
var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
var baseError: webdriver.error.Error = error;
var frame: protractor.stacktrace.Frame = new protractor.stacktrace.Frame();
var baseFrame: webdriver.stacktrace.Frame = frame;
// process module
var snapshot: protractor.stacktrace.Snapshot = new protractor.stacktrace.Snapshot();
var baseSnapshot: webdriver.stacktrace.Snapshot = snapshot;
var isNative: boolean = protractor.process.isNative();
var value: string;
var err: Error = protractor.stacktrace.format(new Error("Error"));
var frames: protractor.stacktrace.Frame[] = protractor.stacktrace.get();
}
value = protractor.process.getEnv('name');
value = protractor.process.getEnv('name', 'default');
function TestWebDriverUntilModule() {
var conditionB: protractor.until.Condition<boolean> = new protractor.until.Condition<boolean>('message', function (driver: webdriver.WebDriver) { return true; });
var conditionBBase: webdriver.until.Condition<boolean> = conditionB;
var conditionWebElement: protractor.until.Condition<webdriver.IWebElement>;
var conditionWebElements: protractor.until.Condition<webdriver.IWebElement[]>;
protractor.process.setEnv('name', 'value');
protractor.process.setEnv('name', 123);
conditionB = protractor.until.ableToSwitchToFrame(5);
var conditionAlert: protractor.until.Condition<webdriver.Alert> = protractor.until.alertIsPresent();
var el: protractor.ElementFinder = element(by.id('id'));
conditionB = protractor.until.elementIsDisabled(el);
conditionB = protractor.until.elementIsEnabled(el);
conditionB = protractor.until.elementIsNotSelected(el);
conditionB = protractor.until.elementIsNotVisible(el);
conditionB = protractor.until.elementIsSelected(el);
conditionB = protractor.until.elementIsVisible(el);
conditionB = protractor.until.elementTextContains(el, 'text');
conditionB = protractor.until.elementTextIs(el, 'text');
conditionB = protractor.until.elementTextMatches(el, /text/);
conditionB = protractor.until.stalenessOf(el);
conditionB = protractor.until.titleContains('text');
conditionB = protractor.until.titleIs('text');
conditionB = protractor.until.titleMatches(/text/);
conditionWebElement = protractor.until.elementLocated(by.id('id'));
conditionWebElements = protractor.until.elementsLocated(by.className('class'));
}
function TestProtractor() {
@@ -133,31 +202,47 @@ function TestProtractor() {
withCapabilities(webdriver.Capabilities.chrome()).
build();
ptor = new protractor.Protractor(driver);
ptor = new protractor.Protractor(driver, 'baseUrl');
ptor = new protractor.Protractor(driver, 'baseUrl', 'rootElement');
ptor = protractor.getInstance();
protractor.setInstance(ptor);
ptor = protractor.wrapDriver(driver);
ptor = protractor.wrapDriver(driver, 'baseUrl');
ptor = protractor.wrapDriver(driver, 'baseUrl', 'rootElement');
ptor = browser;
var actions: protractor.ActionSequence = ptor.actions();
var promise: protractor.promise.Promise<any> = ptor.call(function () { });
var promise: protractor.promise.Promise<any> = ptor.call(function () { }, this);
var promise: protractor.promise.Promise<any> = ptor.call(function (a: number, b: number, c:number) { }, this, 1, 2,3);
promise = ptor.executeAsyncScript('SomeScript');
promise = ptor.executeAsyncScript('SomeScript', 1, 2, 3);
promise = ptor.executeAsyncScript(function () { });
promise = ptor.executeAsyncScript(function (a: number, b: number, c: number) { }, 1, 2, 3);
promise = ptor.executeScript('SomeScript');
promise = ptor.executeScript('SomeScript', 1, 2, 3);
promise = ptor.executeScript(function () { });
promise = ptor.executeScript(function (a: number, b: number, c: number) { }, 1, 2, 3);
ptor = browser.forkNewDriverInstance();
ptor = browser.forkNewDriverInstance(true);
ptor = browser.forkNewDriverInstance(true, false);
driver = ptor.driver;
var baseUrl: string = ptor.baseUrl;
var rootEl: string = ptor.rootEl;
var ignoreSynchronization: boolean = ptor.ignoreSynchronization;
var params: any = ptor.params;
ptor.resetUrl = "url";
ptor.debugger();
ptor.close();
var controlFlow: protractor.promise.ControlFlow = ptor.controlFlow();
var webElement: protractor.WebElement = ptor.findElement(by.css('.class'));
var promise: webdriver.promise.Promise;
promise = ptor.findElements(by.css('.class'));
promise = ptor.isElementPresent(by.css('.class'));
promise = ptor.isElementPresent(webElement);
ptor.findElements(by.css('.class')).then(function (elements: webdriver.WebElement[]) { });
ptor.isElementPresent(by.css('.class')).then(function (present: boolean) { });
ptor.isElementPresent(webElement).then(function (present: boolean) { });
ptor.clearMockModules();
ptor.addMockModule('name', 'script');
@@ -173,16 +258,43 @@ function TestProtractor() {
elementArrayFinder = ptor.$$('.class');
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
var locationAbsUrl: webdriver.promise.Promise<string> = ptor.getLocationAbsUrl();
ptor.setLocation('webaddress.com');
promise = ptor.get('webaddress.com');
promise = ptor.get('webdaddress.com', 45);
var voidPromise: webdriver.promise.Promise<void> = ptor.get('webaddress.com');
voidPromise = ptor.get('webdaddress.com', 45);
voidPromise = ptor.quit();
voidPromise = ptor.sleep(5000);
ptor.refresh();
ptor.refresh(45);
var navigation: webdriver.WebDriverNavigation = ptor.navigate();
ptor.pause();
ptor.pause(8080);
ptor.getAllWindowHandles().then(function (handles: string[]) { });
var capabilities: protractor.promise.Promise<protractor.Capabilities> = ptor.getCapabilities();
var stringPromise: webdriver.promise.Promise<string>;
stringPromise = ptor.getCurrentUrl();
stringPromise = ptor.getPageSource();
stringPromise = ptor.getTitle();
stringPromise = ptor.getWindowHandle();
stringPromise = ptor.takeScreenshot();
ptor.getPageTimeout = 5000;
var session: protractor.promise.Promise<protractor.Session> = ptor.getSession();
var options: webdriver.WebDriverOptions = ptor.manage();
promise = ptor.schedule(new protractor.Command(protractor.CommandName.ACCEPT_ALERT), 'asdf');
var targetLocator: webdriver.WebDriverTargetLocator = ptor.switchTo();
ptor.wait(protractor.until.elementLocated(by.id('id')), 5000).then(function (el: webdriver.IWebElement) { });;
ptor.wait(protractor.until.elementLocated(by.id('id')), 5000, 'message').then(function (el: webdriver.IWebElement) { });;
}
function TestElement() {
@@ -192,80 +304,121 @@ function TestElement() {
function TestElementFinder() {
var elementFinder: protractor.ElementFinder = element(by.id('id'));
var promise: webdriver.promise.Promise;
var voidPromise: webdriver.promise.Promise<void>;
var stringPromise: webdriver.promise.Promise<string>;
var booleanPromise: webdriver.promise.Promise<boolean>;
promise = elementFinder.click();
promise = elementFinder.allowAnimations('string');
promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
promise = elementFinder.getTagName();
promise = elementFinder.getCssValue('display');
promise = elementFinder.getAttribute('atribute');
promise = elementFinder.getText();
promise = elementFinder.getSize();
promise = elementFinder.getLocation();
promise = elementFinder.isEnabled();
promise = elementFinder.isSelected();
promise = elementFinder.submit();
promise = elementFinder.clear();
promise = elementFinder.isDisplayed();
promise = elementFinder.getOuterHtml();
promise = elementFinder.getInnerHtml();
promise = elementFinder.isElementPresent(by.id('id'));
promise = elementFinder.$('.class');
promise = elementFinder.$$('.class');
promise = elementFinder.evaluate('expression');
promise = elementFinder.isPresent();
elementFinder.getId().then(function (id: webdriver.IWebElementId) { });
voidPromise = elementFinder.click();
elementFinder = elementFinder.allowAnimations('string');
voidPromise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
stringPromise = elementFinder.getTagName();
stringPromise = elementFinder.getCssValue('display');
stringPromise = elementFinder.getAttribute('atribute');
stringPromise = elementFinder.getText();
elementFinder.getSize().then(function (size: webdriver.ISize) { });
elementFinder.getLocation().then(function (location: webdriver.ILocation) { });
booleanPromise = elementFinder.isEnabled();
booleanPromise = elementFinder.isSelected();
voidPromise = elementFinder.submit();
voidPromise = elementFinder.clear();
booleanPromise = elementFinder.isDisplayed();
stringPromise = elementFinder.getOuterHtml();
stringPromise = elementFinder.getInnerHtml();
booleanPromise = elementFinder.isElementPresent(by.id('id'));
elementFinder = elementFinder.$('.class');
var finders: protractor.ElementArrayFinder = elementFinder.$$('.class');
elementFinder = elementFinder.evaluate('expression');
booleanPromise = elementFinder.isPresent();
var webElement: webdriver.WebElement;
var webElement: webdriver.WebElement = elementFinder.getWebElement();
finders = elementFinder.all(by.className('class'));
elementFinder = elementFinder.allowAnimations('abc');
elementFinder = elementFinder.clone();
elementFinder = elementFinder.element(by.id('id'));
var b: boolean = elementFinder.isPending();
var locator: webdriver.Locator = elementFinder.locator();
}
function TestElementArrayFinder() {
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.id('id'));
var promise: webdriver.promise.Promise;
var elementFinder: protractor.ElementFinder;
var voidPromise: webdriver.promise.Promise<void>;
var stringPromise: webdriver.promise.Promise<string[]>;
var booleanPromise: webdriver.promise.Promise<boolean[]>;
elementArrayFinder.getId().then(function (id: webdriver.IWebElementId[]) { });
voidPromise = elementArrayFinder.click();
elementArrayFinder = elementArrayFinder.allowAnimations(true);
voidPromise = elementArrayFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
stringPromise = elementArrayFinder.getTagName();
stringPromise = elementArrayFinder.getCssValue('display');
stringPromise = elementArrayFinder.getAttribute('atribute');
stringPromise = elementArrayFinder.getText();
elementArrayFinder.getSize().then(function (size: webdriver.ISize[]) { });
elementArrayFinder.getLocation().then(function (location: webdriver.ILocation[]) { });
booleanPromise = elementArrayFinder.isEnabled();
booleanPromise = elementArrayFinder.isSelected();
voidPromise = elementArrayFinder.submit();
voidPromise = elementArrayFinder.clear();
booleanPromise = elementArrayFinder.isDisplayed();
stringPromise = elementArrayFinder.getOuterHtml();
stringPromise = elementArrayFinder.getInnerHtml();
var finders: protractor.ElementArrayFinder = elementArrayFinder.$$('.class');
elementArrayFinder = elementArrayFinder.evaluate('expression');
finders = elementArrayFinder.all(by.className('class'));
elementArrayFinder = elementArrayFinder.clone();
var b: boolean = elementArrayFinder.isPending();
var locator: webdriver.Locator = elementArrayFinder.locator();
var findersArray: protractor.ElementFinder[] = elementArrayFinder.asElementFinders_();
var driverElementArray: webdriver.WebElement[] = elementArrayFinder.getWebElements();
elementFinder = elementArrayFinder.get(42);
var elementFinder: protractor.ElementFinder = elementArrayFinder.get(42);
elementFinder = elementArrayFinder.first();
elementFinder = elementArrayFinder.last();
promise = elementArrayFinder.count();
promise = elementArrayFinder.asElementFinders_();
elementFinder = elementArrayFinder.toElementFinder_()
var numberPromise: protractor.promise.Promise<number> = elementArrayFinder.count();
elementArrayFinder.each(function(element: protractor.ElementFinder){
// nothing
});
elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){
// nothing
});
elementArrayFinder.filter(function(element: protractor.ElementFinder, index: number){
stringPromise = elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){
return 'abc';
})
elementArrayFinder = elementArrayFinder.filter(function(element: protractor.ElementFinder, index: number){
return element.getText().then((text: string) => {
return text === "foo";
});
});
elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder){
elementArrayFinder.reduce(function (accumulator: string, element: protractor.ElementFinder) {
return element.getText().then((text: string) => {
return accumulator + ',' + text;
});
}, '');
}, '').then(function (result: string) { });
elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder, index: number, array: protractor.ElementFinder[]){
return element.getText().then((text: string) => {
return accumulator + ',' + text;
});
}, '');
}, '').then(function (result: string) { });
elementArrayFinder.then(function(underlyingElementFinders: protractor.ElementFinder[]){
//nothing
});
}
// This function tests the angular specific locator strategies.
// This function tests the locator strategies.
function TestLocatorStrategies() {
var ptor: protractor.Protractor = protractor.getInstance();
var ptor: protractor.Protractor = browser;
var webElement: webdriver.WebElement;
// Protractor Specific Locators
protractor.By.addLocator('customLocator', 'script');
protractor.By.addLocator('customLocator2', function(){
// nothing
});
// Angular specific locators.
webElement = ptor.findElement(protractor.By.binding('binding'));
webElement = ptor.findElement(protractor.By.exactBinding('exactBinding'));
webElement = ptor.findElement(protractor.By.model('model'));
@@ -277,4 +430,23 @@ function TestLocatorStrategies() {
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
webElement = ptor.findElement(protractor.By.cssContainingText('cssSelector', 'search text'));
webElement = ptor.findElement(protractor.By.options('options'));
// One standard locator for good measure.
webElement = ptor.findElement(protractor.By.id('id'));
var el: protractor.ElementFinder;
// Angular specific locators.
el = element(by.binding('binding'));
el = element(by.exactBinding('exactBinding'));
el = element(by.model('model'));
el = element(by.repeater('repeater'));
el = element(by.repeater('repeater').column(0));
el = element(by.repeater('repeater').row(0));
el = element(by.repeater('repeater').row(0).column(0));
el = element(by.buttonText('buttonText'));
el = element(by.partialButtonText('partialButtonText'));
el = element(by.cssContainingText('cssSelector', 'search text'));
el = element(by.options('options'));
// One standard locator for good measure.
el = element(by.id('id'));
}
File diff suppressed because it is too large Load Diff
@@ -1,244 +0,0 @@
/// <reference path="angular-protractor-0.17.0.d.ts" />
function TestWebDriverExports() {
var abstractBuilder: protractor.AbstractBuilder = new protractor.AbstractBuilder();
var baseAbstractBuilder: webdriver.AbstractBuilder = abstractBuilder;
var button: protractor.Button = new protractor.Button();
var baseButton: webdriver.Button = button;
var key: string = protractor.Key.ADD;
var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1);
var driver: protractor.WebDriver = new protractor.Builder().
withCapabilities(protractor.Capabilities.chrome()).
build();
var baseDriver: webdriver.WebDriver = driver;
var action: protractor.ActionSequence = new protractor.ActionSequence(driver);
var baseAction: webdriver.ActionSequence = action;
var alert: protractor.Alert = new protractor.Alert(driver, 'Message');
var baseAlert: webdriver.Alert = alert;
var unhandledAlertError: protractor.UnhandledAlertError = new protractor.UnhandledAlertError('Message', alert);
var baseUnhandledAlertError: webdriver.UnhandledAlertError = unhandledAlertError;
var browser: string = protractor.Browser.ANDROID;
var builder: protractor.Builder = new protractor.Builder();
var baseBuilder: webdriver.Builder = builder;
var capability: string = protractor.Capability.BROWSER_NAME;
var capabilities: protractor.Capabilities = protractor.Capabilities.chrome();
var baseCapabilities: webdriver.Capabilities = capabilities;
var commandName: string = protractor.CommandName.CLICK_ELEMENT;
var command: protractor.Command = new protractor.Command(protractor.CommandName.CLICK);
var baseCommand: webdriver.Command = command;
var eventEmitter: protractor.EventEmitter = new protractor.EventEmitter();
var baseEventEmitter: webdriver.EventEmitter = eventEmitter;
var firefoxDomExecutor: protractor.FirefoxDomExecutor = new protractor.FirefoxDomExecutor();
var baseFirefoxDomExecutor: webdriver.FirefoxDomExecutor = firefoxDomExecutor;
var webElement: protractor.WebElement = new protractor.WebElement(driver, new protractor.promise.Promise());
var baseWebElement: webdriver.WebElement = webElement;
var locator: protractor.Locator = new protractor.Locator('id', 'ABC');
var baseLocator: webdriver.Locator = locator;
var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android());
var baseSession: webdriver.Session = session;
locator = protractor.By.name('name');
// logging module
var levelName: string = protractor.logging.LevelName.ALL;
var loggingType: string = protractor.logging.Type.CLIENT;
var level: webdriver.logging.Level = protractor.logging.Level.ALL;
var entry: protractor.logging.Entry = new protractor.logging.Entry(protractor.logging.Level.ALL, 'Message');
var baseEntry: webdriver.logging.Entry = entry;
level = protractor.logging.getLevel('DEBUG');
protractor.logging.Preferences = { a: 123 };
// promise module
var promise: protractor.promise.Promise = new protractor.promise.Promise();
var basePromise: webdriver.promise.Promise = promise;
var deferred: protractor.promise.Deferred = new protractor.promise.Deferred();
var baseDeferred: webdriver.promise.Deferred = deferred;
var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow();
var baseFlow: webdriver.promise.ControlFlow = flow;
protractor.promise.asap(promise, function(value: any){ return true; });
protractor.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; });
promise = protractor.promise.checkedNodeCall(function(err: any, value: any) { return 123; });
flow = protractor.promise.controlFlow();
promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
deferred = protractor.promise.defer(function() {});
deferred = protractor.promise.defer(function(reason?: any) {});
promise = protractor.promise.delayed(123);
promise = protractor.promise.fulfilled();
promise = protractor.promise.fulfilled({a: 123});
promise = protractor.promise.fullyResolved({a: 123});
var isPromise: boolean = protractor.promise.isPromise('ABC');
promise = protractor.promise.rejected({a: 123});
protractor.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
promise = protractor.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; });
// error module
var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
var baseError: webdriver.error.Error = error;
// process module
var isNative: boolean = protractor.process.isNative();
var value: string;
value = protractor.process.getEnv('name');
value = protractor.process.getEnv('name', 'default');
protractor.process.setEnv('name', 'value');
protractor.process.setEnv('name', 123);
}
function TestProtractor() {
var ptor: protractor.Protractor;
var driver: webdriver.WebDriver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
ptor = new protractor.Protractor(driver);
ptor = new protractor.Protractor(driver, 'baseUrl');
ptor = new protractor.Protractor(driver, 'baseUrl', 'rootElement');
ptor = protractor.getInstance();
protractor.setInstance(ptor);
ptor = protractor.wrapDriver(driver);
ptor = protractor.wrapDriver(driver, 'baseUrl');
ptor = protractor.wrapDriver(driver, 'baseUrl', 'rootElement');
ptor = browser;
driver = ptor.driver;
var baseUrl: string = ptor.baseUrl;
var rootEl: string = ptor.rootEl;
var ignoreSynchronization: boolean = ptor.ignoreSynchronization;
var params: any = ptor.params;
ptor.debugger();
ptor.clearMockModules();
ptor.addMockModule('name', 'script');
ptor.addMockModule('name', function() {});
ptor.waitForAngular();
var elementFinder: protractor.ElementFinder;
elementFinder = ptor.element(by.id('ABC'));
elementFinder = ptor.$('.class');
var elementArrayFinder: protractor.ElementArrayFinder = ptor.$$('.class');
var webElement: webdriver.WebElement = ptor.wrapWebElement(new webdriver.WebElement(driver, 'id'));
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
}
function TestElement() {
var elementFinder: protractor.ElementFinder = element(by.id('id'));
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.className('class'));
}
function TestElementFinder() {
var elementFinder: protractor.ElementFinder = element(by.id('id'));
var promise: webdriver.promise.Promise;
promise = elementFinder.click();
promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
promise = elementFinder.getTagName();
promise = elementFinder.getCssValue('display');
promise = elementFinder.getAttribute('atribute');
promise = elementFinder.getText();
promise = elementFinder.getSize();
promise = elementFinder.getLocation();
promise = elementFinder.isEnabled();
promise = elementFinder.isSelected();
promise = elementFinder.submit();
promise = elementFinder.clear();
promise = elementFinder.isDisplayed();
promise = elementFinder.getOuterHtml();
promise = elementFinder.getInnerHtml();
promise = elementFinder.isElementPresent(by.id('id'));
promise = elementFinder.isElementPresent(by.js('function(a, b, c) {}'), 1, 2, 3);
promise = elementFinder.findElements(by.className('class'));
promise = elementFinder.findElements(by.js('function(a, b, c) {}'), 1, 2, 3);
promise = elementFinder.$$('.class');
promise = elementFinder.evaluate('expression');
promise = elementFinder.isPresent();
var webElement: webdriver.WebElement;
webElement = elementFinder.$('.class');
webElement = elementFinder.findElement(by.id('id'));
webElement = elementFinder.findElement(by.js('function(a, b, c) {}'), 1, 2, 3);
webElement = elementFinder.find();
}
// This function tests the angular specific locator strategies.
function TestLocatorStrategies() {
var ptor: protractor.Protractor = protractor.getInstance();
var webElement: webdriver.WebElement;
// Protractor Specific Locators
webElement = ptor.findElement(protractor.By.binding('binding'));
webElement = ptor.findElement(protractor.By.select('select'));
webElement = ptor.findElement(protractor.By.selectedOption('selectedOptions'));
webElement = ptor.findElement(protractor.By.input('input'));
webElement = ptor.findElement(protractor.By.model('model'));
webElement = ptor.findElement(protractor.By.textarea('textarea'));
webElement = ptor.findElement(protractor.By.repeater('repeater'));
webElement = ptor.findElement(protractor.By.buttonText('buttonText'));
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
}
// This function tests the methods that were added to the base WebElement class
function TestWebElements() {
var ptor: protractor.Protractor = protractor.getInstance();
var webElement: protractor.WebElement;
var promise: webdriver.promise.Promise;
webElement = ptor.findElement(by.id('id')).$('.class');
promise = ptor.findElement(by.id('id')).$$('.class');
promise = ptor.findElement(by.id('id')).evaluate('something');
webElement = webElement.findElement(by.id('id')).$('.class');
promise = webElement.findElement(by.id('id')).$$('.class');
promise = webElement.findElement(by.id('id')).evaluate('something');
}
-906
View File
@@ -1,906 +0,0 @@
// Type definitions for Angular Protractor 0.17.0
// Project: https://github.com/angular/protractor
// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../../selenium-webdriver/selenium-webdriver.d.ts" />
declare module protractor {
//region Wrapped webdriver Items
class AbstractBuilder extends webdriver.AbstractBuilder {}
class ActionSequence extends webdriver.ActionSequence {}
class Alert extends webdriver.Alert {}
class Builder extends webdriver.Builder {}
class Button extends webdriver.Button {}
class Capabilities extends webdriver.Capabilities {}
class Command extends webdriver.Command {}
class EventEmitter extends webdriver.EventEmitter {}
class FirefoxDomExecutor extends webdriver.FirefoxDomExecutor {}
class Locator extends webdriver.Locator {}
class Session extends webdriver.Session {}
class WebDriver extends webdriver.WebDriver {}
class Browser extends webdriver.Browser {}
class Capability extends webdriver.Capability {}
class CommandName extends webdriver.CommandName {}
class Key extends webdriver.Key {}
class UnhandledAlertError extends webdriver.UnhandledAlertError {}
class WebElement extends webdriver.WebElement {
/**
* Shortcut for querying the document directly with css.
*
* @param {string} selector a css selector
* @see webdriver.WebElement.findElement
* @return {!protractor.WebElement}
*/
$(selector: string): protractor.WebElement;
/**
* Shortcut for querying the document directly with css.
*
* @param {string} selector a css selector
* @see webdriver.WebElement.findElements
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
* array of the located {@link webdriver.WebElement}s.
*/
$$(selector: string): webdriver.promise.Promise;
/**
* Evalates the input as if it were on the scope of the current element.
* @param {string} expression
*
* @return {!webdriver.promise.Promise} A promise that will resolve to the
* evaluated expression. The result will be resolved as in
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
* be resolved as is, functions will be converted to string, and elements
* will be returned as a WebElement.
*/
evaluate(expression: string): webdriver.promise.Promise;
/**
* Schedule a command to find a descendant of this element. If the element
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
* be returned by the driver. Unlike other commands, this error cannot be
* suppressed. In other words, scheduling a command to find an element doubles
* as an assert that the element is present on the page. To test whether an
* element is present on the page, use {@code #isElementPresent} instead.
* <p/>
* The search criteria for find an element may either be a
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
* is one of the accepted locator strategies, as defined by
* {@code webdriver.Locator.Strategy}. For example, the following two
* statements are equivalent:
* <code><pre>
* var e1 = element.findElement(By.id('foo'));
* var e2 = element.findElement({id:'foo'});
* </pre></code>
* <p/>
* Note that JS locator searches cannot be restricted to a subtree. All such
* searches are delegated to this instance's parent WebDriver.
*
* @param {webdriver.Locator|Object.<string>} locator The locator
* strategy to use when searching for the element.
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
* using a JavaScript locator. Otherwise ignored.
* @return {protractor.WebElement} A WebElement that can be used to issue
* commands against the located element. If the element is not found, the
* element will be invalidated and all scheduled commands aborted.
*/
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
}
module command {
class Command extends webdriver.Command {}
class CommandName extends webdriver.CommandName {}
}
module error {
class Error extends webdriver.error.Error {}
class ErrorCode extends webdriver.error.ErrorCode {}
}
module events {
class EventEmitter extends webdriver.EventEmitter {}
}
module logging {
var Preferences: any;
class LevelName extends webdriver.logging.LevelName {}
class Type extends webdriver.logging.Type {}
class Level extends webdriver.logging.Level {}
class Entry extends webdriver.logging.Entry {}
function getLevel(nameOrValue: string): webdriver.logging.Level;
function getLevel(nameOrValue: number): webdriver.logging.Level;
}
module promise {
class Promise extends webdriver.promise.Promise {}
class Deferred extends webdriver.promise.Deferred {}
class ControlFlow extends webdriver.promise.ControlFlow {}
/**
* @return {!webdriver.promise.ControlFlow} The currently active control flow.
*/
function controlFlow(): webdriver.promise.ControlFlow;
/**
* Creates a new control flow. The provided callback will be invoked as the
* first task within the new flow, with the flow as its sole argument. Returns
* a promise that resolves to the callback result.
* @param {function(!webdriver.promise.ControlFlow)} callback The entry point
* to the newly created flow.
* @return {!webdriver.promise.Promise} A promise that resolves to the callback
* result.
*/
function createFlow(callback: (flow: webdriver.promise.ControlFlow) => any): webdriver.promise.Promise;
/**
* Determines whether a {@code value} should be treated as a promise.
* Any object whose "then" property is a function will be considered a promise.
*
* @param {*} value The value to test.
* @return {boolean} Whether the value is a promise.
*/
function isPromise(value: any): boolean;
/**
* Creates a promise that will be resolved at a set time in the future.
* @param {number} ms The amount of time, in milliseconds, to wait before
* resolving the promise.
* @return {!webdriver.promise.Promise} The promise.
*/
function delayed(ms: number): webdriver.promise.Promise;
/**
* Creates a new deferred object.
* @param {Function=} opt_canceller Function to call when cancelling the
* computation of this instance's value.
* @return {!webdriver.promise.Deferred} The new deferred object.
*/
function defer(opt_canceller?: any): webdriver.promise.Deferred;
/**
* Creates a promise that has been resolved with the given value.
* @param {*=} opt_value The resolved value.
* @return {!webdriver.promise.Promise} The resolved promise.
*/
function fulfilled(opt_value?: any): webdriver.promise.Promise;
/**
* Creates a promise that has been rejected with the given reason.
* @param {*=} opt_reason The rejection reason; may be any value, but is
* usually an Error or a string.
* @return {!webdriver.promise.Promise} The rejected promise.
*/
function rejected(opt_reason?: any): webdriver.promise.Promise;
/**
* Wraps a function that is assumed to be a node-style callback as its final
* argument. This callback takes two arguments: an error value (which will be
* null if the call succeeded), and the success value as the second argument.
* If the call fails, the returned promise will be rejected, otherwise it will
* be resolved with the result.
* @param {!Function} fn The function to wrap.
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
* result of the provided function's callback.
*/
function checkedNodeCall(fn: (error: any, value: any) => any): webdriver.promise.Promise;
/**
* Registers an observer on a promised {@code value}, returning a new promise
* that will be resolved when the value is. If {@code value} is not a promise,
* then the return promise will be immediately resolved.
* @param {*} value The value to observe.
* @param {Function=} opt_callback The function to call when the value is
* resolved successfully.
* @param {Function=} opt_errback The function to call when the value is
* rejected.
* @return {!webdriver.promise.Promise} A new promise.
*/
function when(value: any, opt_callback?: (value: any) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise;
/**
* Invokes the appropriate callback function as soon as a promised
* {@code value} is resolved. This function is similar to
* {@code webdriver.promise.when}, except it does not return a new promise.
* @param {*} value The value to observe.
* @param {Function} callback The function to call when the value is
* resolved successfully.
* @param {Function=} opt_errback The function to call when the value is
* rejected.
*/
function asap(value: any, callback: (value: any) => any, opt_errback?: (error: any) => any): void;
/**
* Returns a promise that will be resolved with the input value in a
* fully-resolved state. If the value is an array, each element will be fully
* resolved. Likewise, if the value is an object, all keys will be fully
* resolved. In both cases, all nested arrays and objects will also be
* fully resolved. All fields are resolved in place; the returned promise will
* resolve on {@code value} and not a copy.
*
* Warning: This function makes no checks against objects that contain
* cyclical references:
*
* var value = {};
* value['self'] = value;
* webdriver.promise.fullyResolved(value); // Stack overflow.
*
* @param {*} value The value to fully resolve.
* @return {!webdriver.promise.Promise} A promise for a fully resolved version
* of the input value.
*/
function fullyResolved(value: any): webdriver.promise.Promise;
/**
* Changes the default flow to use when no others are active.
* @param {!webdriver.promise.ControlFlow} flow The new default flow.
* @throws {Error} If the default flow is not currently active.
*/
function setDefaultFlow(flow: webdriver.promise.ControlFlow): void;
}
module process {
/**
* Queries for a named environment variable.
* @param {string} name The name of the environment variable to look up.
* @param {string=} opt_default The default value if the named variable is not
* defined.
* @return {string} The queried environment variable.
*/
function getEnv(name: string, opt_default?: string): string;
/**
* @return {boolean} Whether the current process is Node's native process
* object.
*/
function isNative(): boolean;
/**
* Sets an environment value. If the new value is either null or undefined, the
* environment variable will be cleared.
* @param {string} name The value to set.
* @param {*} value The new value; will be coerced to a string.
*/
function setEnv(name: string, value: any): void;
}
//endregion
interface Element {
(locator: webdriver.Locator): ElementFinder;
all(locator: webdriver.Locator): ElementArrayFinder;
}
interface ElementFinder {
/**
* Schedules a command to click on this element.
* @return {!webdriver.promise.Promise} A promise that will be resolved when
* the click command has completed.
*/
click(): webdriver.promise.Promise;
/**
* Schedules a command to type a sequence on the DOM element represented by this
* instance.
* <p/>
* Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is
* processed in the keysequence, that key state is toggled until one of the
* following occurs:
* <ul>
* <li>The modifier key is encountered again in the sequence. At this point the
* state of the key is toggled (along with the appropriate keyup/down events).
* </li>
* <li>The {@code webdriver.Key.NULL} key is encountered in the sequence. When
* this key is encountered, all modifier keys current in the down state are
* released (with accompanying keyup events). The NULL key can be used to
* simulate common keyboard shortcuts:
* <code>
* element.sendKeys("text was",
* webdriver.Key.CONTROL, "a", webdriver.Key.NULL,
* "now text is");
* // Alternatively:
* element.sendKeys("text was",
* webdriver.Key.chord(webdriver.Key.CONTROL, "a"),
* "now text is");
* </code></li>
* <li>The end of the keysequence is encountered. When there are no more keys
* to type, all depressed modifier keys are released (with accompanying keyup
* events).
* </li>
* </ul>
* <strong>Note:</strong> On browsers where native keyboard events are not yet
* supported (e.g. Firefox on OS X), key events will be synthesized. Special
* punctionation keys will be synthesized according to a standard QWERTY en-us
* keyboard layout.
*
* @param {...string} var_args The sequence of keys to
* type. All arguments will be joined into a single sequence (var_args is
* permitted for convenience).
* @return {!webdriver.promise.Promise} A promise that will be resolved when all
* keys have been typed.
*/
sendKeys(...var_args: string[]): webdriver.promise.Promise;
/**
* Schedules a command to query for the tag/node name of this element.
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
* element's tag name.
*/
getTagName(): webdriver.promise.Promise;
/**
* Schedules a command to query for the computed style of the element
* represented by this instance. If the element inherits the named style from
* its parent, the parent will be queried for its value. Where possible, color
* values will be converted to their hex representation (e.g. #00ff00 instead of
* rgb(0, 255, 0)).
* <p/>
* <em>Warning:</em> the value returned will be as the browser interprets it, so
* it may be tricky to form a proper assertion.
*
* @param {string} cssStyleProperty The name of the CSS style property to look
* up.
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
* requested CSS value.
*/
getCssValue(cssStyleProperty: string): webdriver.promise.Promise;
/**
* Schedules a command to query for the value of the given attribute of the
* element. Will return the current value even if it has been modified after the
* page has been loaded. More exactly, this method will return the value of the
* given attribute, unless that attribute is not present, in which case the
* value of the property with the same name is returned. If neither value is
* set, null is returned. The "style" attribute is converted as best can be to a
* text representation with a trailing semi-colon. The following are deemed to
* be "boolean" attributes and will be returned as thus:
*
* <p>async, autofocus, autoplay, checked, compact, complete, controls, declare,
* defaultchecked, defaultselected, defer, disabled, draggable, ended,
* formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope,
* loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open,
* paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
* selected, spellcheck, truespeed, willvalidate
*
* <p>Finally, the following commonly mis-capitalized attribute/property names
* are evaluated as expected:
* <ul>
* <li>"class"
* <li>"readonly"
* </ul>
* @param {string} attributeName The name of the attribute to query.
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
* attribute's value.
*/
getAttribute(attributeName: string): webdriver.promise.Promise;
/**
* Get the visible (i.e. not hidden by CSS) innerText of this element, including
* sub-elements, without any leading or trailing whitespace.
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
* element's visible text.
*/
getText(): webdriver.promise.Promise;
/**
* Schedules a command to compute the size of this element's bounding box, in
* pixels.
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
* element's size as a {@code {width:number, height:number}} object.
*/
getSize(): webdriver.promise.Promise;
/**
* Schedules a command to compute the location of this element in page space.
* @return {!webdriver.promise.Promise} A promise that will be resolved to the
* element's location as a {@code {x:number, y:number}} object.
*/
getLocation(): webdriver.promise.Promise;
/**
* Schedules a command to query whether the DOM element represented by this
* instance is enabled, as dicted by the {@code disabled} attribute.
* @return {!webdriver.promise.Promise} A promise that will be resolved with
* whether this element is currently enabled.
*/
isEnabled(): webdriver.promise.Promise;
/**
* Schedules a command to query whether this element is selected.
* @return {!webdriver.promise.Promise} A promise that will be resolved with
* whether this element is currently selected.
*/
isSelected(): webdriver.promise.Promise;
/**
* Schedules a command to submit the form containing this element (or this
* element if it is a FORM element). This command is a no-op if the element is
* not contained in a form.
* @return {!webdriver.promise.Promise} A promise that will be resolved when
* the form has been submitted.
*/
submit(): webdriver.promise.Promise;
/**
* Schedules a command to clear the {@code value} of this element. This command
* has no effect if the underlying DOM element is neither a text INPUT element
* nor a TEXTAREA element.
* @return {!webdriver.promise.Promise} A promise that will be resolved when
* the element has been cleared.
*/
clear(): webdriver.promise.Promise;
/**
* Schedules a command to test whether this element is currently displayed.
* @return {!webdriver.promise.Promise} A promise that will be resolved with
* whether this element is currently visible on the page.
*/
isDisplayed(): webdriver.promise.Promise;
/**
* Schedules a command to retrieve the outer HTML of this element.
* @return {!webdriver.promise.Promise} A promise that will be resolved with
* the element's outer HTML.
*/
getOuterHtml(): webdriver.promise.Promise;
/**
* Schedules a command to retrieve the inner HTML of this element.
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
* element's inner HTML.
*/
getInnerHtml(): webdriver.promise.Promise;
/**
* Schedules a command to test if there is at least one descendant of this
* element that matches the given search criteria.
*
* <p>Note that JS locator searches cannot be restricted to a subtree of the
* DOM. All such searches are delegated to this instance's parent WebDriver.
*
* @param {webdriver.Locator|Object.<string>} locator The locator
* strategy to use when searching for the element.
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
* using a JavaScript locator. Otherwise ignored.
* @return {!webdriver.promise.Promise} A promise that will be resolved with
* whether an element could be located on the page.
*/
isElementPresent(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
isElementPresent(locator: any, ...var_args: any[]): webdriver.promise.Promise;
/**
* Schedules a command to find all of the descendants of this element that match
* the given search criteria.
* <p/>
* Note that JS locator searches cannot be restricted to a subtree. All such
* searches are delegated to this instance's parent WebDriver.
*
* @param {webdriver.Locator|Object.<string>} locator The locator
* strategy to use when searching for the elements.
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
* using a JavaScript locator. Otherwise ignored.
* @return {!webdriver.promise.Promise} A promise that will be resolved with an
* array of located {@link webdriver.WebElement}s.
*/
findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise;
/**
* Shortcut for querying the document directly with css.
*
* @param {string} selector a css selector
* @see webdriver.WebElement.findElement
* @return {!protractor.WebElement}
*/
$(selector: string): protractor.WebElement;
/**
* Shortcut for querying the document directly with css.
*
* @param {string} selector a css selector
* @see webdriver.WebElement.findElements
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
* array of the located {@link webdriver.WebElement}s.
*/
$$(selector: string): webdriver.promise.Promise;
/**
* Schedule a command to find a descendant of this element. If the element
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
* be returned by the driver. Unlike other commands, this error cannot be
* suppressed. In other words, scheduling a command to find an element doubles
* as an assert that the element is present on the page. To test whether an
* element is present on the page, use {@code #isElementPresent} instead.
* <p/>
* The search criteria for find an element may either be a
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
* is one of the accepted locator strategies, as defined by
* {@code webdriver.Locator.Strategy}. For example, the following two
* statements are equivalent:
* <code><pre>
* var e1 = element.findElement(By.id('foo'));
* var e2 = element.findElement({id:'foo'});
* </pre></code>
* <p/>
* Note that JS locator searches cannot be restricted to a subtree. All such
* searches are delegated to this instance's parent WebDriver.
*
* @param {webdriver.Locator|Object.<string>} locator The locator
* strategy to use when searching for the element.
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
* using a JavaScript locator. Otherwise ignored.
* @return {protractor.WebElement} A WebElement that can be used to issue
* commands against the located element. If the element is not found, the
* element will be invalidated and all scheduled commands aborted.
*/
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
/**
* Evalates the input as if it were on the scope of the current element.
* @param {string} expression
*
* @return {!webdriver.promise.Promise} A promise that will resolve to the
* evaluated expression. The result will be resolved as in
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
* be resolved as is, functions will be converted to string, and elements
* will be returned as a WebElement.
*/
evaluate(expression: string): webdriver.promise.Promise;
/**
* Use as: element(locator).element(locator)
* Calls to element may be chained to find elements within a parent.
*
* @param {webdriver.Locator} The locator that will be used to find descendents.
*
* @return {protractor.ElementFinder} the descendent element found by the locator
*/
element(locator: webdriver.Locator): protractor.ElementFinder;
/**
* Use as: element(locator).all(locator)
* Calls to element may be chained to find an array of elements within a parent.
*
* @param {webdriver.Locator} The locator that will be used to find descendents.
*
* @return {protractor.ElementArrayFinder} the descendent elements found by the locator
*/
all(locator: webdriver.Locator): protractor.ElementArrayFinder;
find(): protractor.WebElement;
isPresent(): webdriver.promise.Promise;
}
interface ElementArrayFinder{
count(): webdriver.promise.Promise;
get(index: number): protractor.WebElement;
first(): protractor.WebElement;
last(): protractor.WebElement;
then(fn: (value: any) => any): webdriver.promise.Promise;
}
class LocatorWithColumn extends webdriver.Locator {
column(index: number): webdriver.Locator;
}
class RepeaterLocator extends LocatorWithColumn {
row(index: number): LocatorWithColumn;
}
interface IProtractorLocatorStrategy extends webdriver.ILocatorStrategy {
/**
* Add a locator to this instance of ProtractorBy. This locator can then be
* used with element(by.<name>(<args>)).
*
* @param {string} name
* @param {function|string} script A script to be run in the context of
* the browser. This script will be passed an array of arguments
* that begins with the element scoping the search, and then
* contains any args passed into the locator. It should return
* an array of elements.
*/
addLocator(name: string, script: any): void;
/**
* Usage:
* <span>{{status}}</span>
* var status = element(by.binding('{{status}}'));
*/
binding(bindingDescriptor: string): webdriver.Locator;
/**
* Usage:
* <select ng-model="user" ng-options="user.name for user in users"></select>
* element(by.select("user"));
*/
select(model: string): webdriver.Locator;
/**
* Usage:
* <select ng-model="user" ng-options="user.name for user in users"></select>
* element(by.selectedOption("user"));
*/
selectedOption(model: string): webdriver.Locator;
/**
* @DEPRECATED - use 'model' instead.
* Usage:
* <input ng-model="user" type="text"/>
* element(by.input('user'));
*/
input(model: string): webdriver.Locator;
/**
* Usage:
* <input ng-model="user" type="text"/>
* element(by.model('user'));
*/
model(model: string): webdriver.Locator;
/**
* Usage:
* <textarea ng-model="user"></textarea>
* element(by.textarea("user"));
*/
textarea(model: string): webdriver.Locator;
/**
* Usage:
* <div ng-repeat = "cat in pets">
* <span>{{cat.name}}</span>
* <span>{{cat.age}}</span>
* </div>
*
* // Returns the DIV for the second cat.
* var secondCat = element(by.repeater("cat in pets").row(2));
* // Returns the SPAN for the first cat's name.
* var firstCatName = element(
* by.repeater("cat in pets").row(1).column("{{cat.name}}"));
* // Returns a promise that resolves to an array of WebElements from a column
* var ages = element(
* by.repeater("cat in pets").column("{{cat.age}}"));
* // Returns a promise that resolves to an array of WebElements containing
* // all rows of the repeater.
* var rows = element(by.repeater("cat in pets"));
*/
repeater(repeatDescriptor: string): RepeaterLocator;
buttonText(searchText: string): webdriver.Locator;
partialButtonText(searchText: string): webdriver.Locator;
}
var By: IProtractorLocatorStrategy;
class Protractor extends webdriver.WebDriver {
//region Constructors
/**
* @param {webdriver.WebDriver} webdriver
* @param {string=} opt_baseUrl A base URL to run get requests against.
* @param {string=body} opt_rootElement Selector element that has an ng-app in
* scope.
* @constructor
*/
constructor(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string);
//endregion
//region Properties
/**
* The wrapped webdriver instance. Use this to interact with pages that do
* not contain Angular (such as a log-in screen).
*
* @type {webdriver.WebDriver}
*/
driver: webdriver.WebDriver;
/**
* All get methods will be resolved against this base URL. Relative URLs are =
* resolved the way anchor tags resolve.
*
* @type {string}
*/
baseUrl: string;
/**
* The css selector for an element on which to find Angular. This is usually
* 'body' but if your ng-app is on a subsection of the page it may be
* a subelement.
*
* @type {string}
*/
rootEl: string;
/**
* If true, Protractor will not attempt to synchronize with the page before
* performing actions. This can be harmful because Protractor will not wait
* until $timeouts and $http calls have been processed, which can cause
* tests to become flaky. This should be used only when necessary, such as
* when a page continuously polls an API using $timeout.
*
* @type {boolean}
*/
ignoreSynchronization: boolean;
/**
* An object that holds custom test parameters.
*
* @type {Object}
*/
params: any;
//endregion
//region Methods
/**
* Helper function for finding elements.
*
* @type {function(webdriver.Locator): ElementFinder}
*/
element(locator: webdriver.Locator): ElementFinder;
/**
* Helper function for finding elements by css.
*
* @type {function(string): ElementFinder}
*/
$(cssLocator: string): ElementFinder;
/**
* Helper function for finding arrays of elements by css.
*
* @type {function(string): ElementArrayFinder}
*/
$$(cssLocator: string): ElementArrayFinder;
/**
* Instruct webdriver to wait until Angular has finished rendering and has
* no outstanding $http calls before continuing.
*
* @return {!webdriver.promise.Promise} A promise that will resolve to the
* scripts return value.
*/
waitForAngular(): webdriver.promise.Promise;
/**
* Wrap a webdriver.WebElement with protractor specific functionality.
*
* @param {webdriver.WebElement} element
* @return {protractor.WebElement} the wrapped web element.
*/
wrapWebElement(element: webdriver.WebElement): protractor.WebElement;
/**
* Add a module to load before Angular whenever Protractor.get is called.
* Modules will be registered after existing modules already on the page,
* so any module registered here will override preexisting modules with the same
* name.
*
* @param {!string} name The name of the module to load or override.
* @param {!string|Function} script The JavaScript to load the module.
*/
addMockModule(name: string, script: string): void;
addMockModule(name: string, script: any): void;
/**
* Clear the list of registered mock modules.
*/
clearMockModules(): void;
/**
* Returns the current absolute url from AngularJS.
*/
getLocationAbsUrl(): webdriver.promise.Promise;
/**
* Pauses the test and injects some helper functions into the browser, so that
* debugging may be done in the browser console.
*
* This should be used under node in debug mode, i.e. with
* protractor debug <configuration.js>
*
* While in the debugger, commands can be scheduled through webdriver by
* entering the repl:
* debug> repl
* Press Ctrl + C to leave rdebug repl
* > ptor.findElement(protractor.By.input('user').sendKeys('Laura'));
* > ptor.debugger();
* debug> c
*
* This will run the sendKeys command as the next task, then re-enter the
* debugger.
*/
debugger(): void;
/**
* Schedule a command to find an element on the page. If the element cannot be
* found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will be returned
* by the driver. Unlike other commands, this error cannot be suppressed. In
* other words, scheduling a command to find an element doubles as an assert
* that the element is present on the page. To test whether an element is
* present on the page, use {@code #isElementPresent} instead.
*
* <p>The search criteria for find an element may either be a
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
* is one of the accepted locator strategies, as defined by
* {@code webdriver.Locator.Strategy}. For example, the following two statements
* are equivalent:
* <code><pre>
* var e1 = driver.findElement(By.id('foo'));
* var e2 = driver.findElement({id:'foo'});
* </pre></code>
*
* <p>When running in the browser, a WebDriver cannot manipulate DOM elements
* directly; it may do so only through a {@link webdriver.WebElement} reference.
* This function may be used to generate a WebElement from a DOM element. A
* reference to the DOM element will be stored in a known location and this
* driver will attempt to retrieve it through {@link #executeScript}. If the
* element cannot be found (eg, it belongs to a different document than the
* one this instance is currently focused on), a
* {@link bot.ErrorCode.NO_SUCH_ELEMENT} error will be returned.
*
* @param {!(webdriver.Locator|Object.<string>|Element)} locatorOrElement The
* locator strategy to use when searching for the element, or the actual
* DOM element to be located by the server.
* @param {...} var_args Arguments to pass to {@code #executeScript} if using a
* JavaScript locator. Otherwise ignored.
* @return {!protractor.WebElement} A WebElement that can be used to issue
* commands against the located element. If the element is not found, the
* element will be invalidated and all scheduled commands aborted.
*/
findElement(locatorOrElement: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
findElement(locatorOrElement: any, ...var_args: any[]): protractor.WebElement;
//endregion
}
/**
* Create a new instance of Protractor by wrapping a webdriver instance.
*
* @param {webdriver.WebDriver} webdriver The configured webdriver instance.
* @param {string=} opt_baseUrl A URL to prepend to relative gets.
* @return {Protractor}
*/
function wrapDriver(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string): Protractor;
/**
* Set a singleton instance of protractor.
* @param {Protractor} ptor
*/
function setInstance(ptor: Protractor): void;
/**
* Get the singleton instance.
* @return {Protractor}
*/
function getInstance(): Protractor;
}
interface cssSelectorHelper {
(cssLocator: string): protractor.ElementFinder;
}
declare var browser: protractor.Protractor;
declare var by: protractor.IProtractorLocatorStrategy;
declare var element: protractor.Element;
declare var $: cssSelectorHelper;
declare var $$: cssSelectorHelper;
declare module 'protractor' {
export = protractor;
}
@@ -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
+64
View File
@@ -0,0 +1,64 @@
/// <reference path="angular-scroll.d.ts" />
module TestApp {
class TestController {
constructor($scope: ng.IScope, $document: duScroll.IDocumentService) {
var positionFromTop = 400;
var positionFromLeft = 200;
var offsetInPixels = 100;
var durationInMillis = 2000;
var someElement: ng.IAugmentedJQuery;
$document.duScrollTo(positionFromLeft, positionFromTop);
$document.duScrollTo(positionFromLeft, positionFromTop, durationInMillis).then(this.onScrollCompleted);
$document.duScrollTo(positionFromLeft, positionFromTop, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
$document.duScrollTo(someElement);
$document.duScrollTo(someElement, offsetInPixels);
$document.duScrollTo(someElement, offsetInPixels, durationInMillis).then(this.onScrollCompleted);
$document.duScrollTo(someElement, offsetInPixels, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
$document.duScrollToElement(someElement);
$document.duScrollToElement(someElement, offsetInPixels);
$document.duScrollToElement(someElement, offsetInPixels, durationInMillis).then(this.onScrollCompleted);
$document.duScrollToElement(someElement, offsetInPixels, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
$document.duScrollToElementAnimated(someElement).then(this.onScrollCompleted);
$document.duScrollToElementAnimated(someElement, offsetInPixels).then(this.onScrollCompleted);
$document.duScrollToElementAnimated(someElement, offsetInPixels, durationInMillis).then(this.onScrollCompleted);
$document.duScrollToElementAnimated(someElement, offsetInPixels, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
$document.duScrollTop(positionFromTop);
$document.duScrollTop(positionFromTop, durationInMillis).then(this.onScrollCompleted);
$document.duScrollTop(positionFromTop, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
$document.duScrollTopAnimated(positionFromTop).then(this.onScrollCompleted);
$document.duScrollTopAnimated(positionFromTop, durationInMillis).then(this.onScrollCompleted);
$document.duScrollTopAnimated(positionFromTop, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
$document.duScrollLeft(positionFromLeft);
$document.duScrollLeft(positionFromLeft, durationInMillis).then(this.onScrollCompleted);
$document.duScrollLeft(positionFromLeft, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
$document.duScrollLeftAnimated(positionFromLeft).then(this.onScrollCompleted);
$document.duScrollLeftAnimated(positionFromLeft, durationInMillis).then(this.onScrollCompleted);
$document.duScrollLeftAnimated(positionFromLeft, durationInMillis, this.invertedEasingFn).then(this.onScrollCompleted);
var verticalPosition: number = $document.duScrollTop();
var horixontalPosition: number = $document.duScrollLeft();
}
private invertedEasingFn = (x: number): number => {
return 1 - x;
}
private onScrollCompleted = (): void => {
console.log('Done scrolling');
}
}
angular.module('testApp', ['duScroll'])
.controller('testController', TestController);
}
+44
View File
@@ -0,0 +1,44 @@
// Type definitions for angular-scroll
// Project: https://github.com/oblador/angular-scroll
// Definitions by: Sam Herrmann <https://github.com/samherrmann>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module duScroll {
/**
* Extends the angular.element object returned by the $document sercive with a few jQuery like functions.
* see https://github.com/oblador/angular-scroll#angularelement-scroll-api
*/
interface IDocumentService extends ng.IDocumentService {
duScrollTo(left: number, top: number): void;
duScrollTo(left: number, top: number, duration: number, easing?: Function): ng.IPromise<void>;
duScrollTo(element: ng.IAugmentedJQuery, offset?: number): void;
duScrollTo(element: ng.IAugmentedJQuery, offset: number, duration: number, easing?: Function): ng.IPromise<void>;
duScrollToElement(element: ng.IAugmentedJQuery, offset?: number): void;
duScrollToElement(element: ng.IAugmentedJQuery, offset: number, duration: number, easing?: Function): ng.IPromise<void>;
duScrollToElementAnimated(element: ng.IAugmentedJQuery, offset?: number): ng.IPromise<void>;
duScrollToElementAnimated(element: ng.IAugmentedJQuery, offset: number, duration: number, easing?: Function): ng.IPromise<void>;
duScrollTop(top: number): void;
duScrollTop(top: number, duration: number, easing?: Function): ng.IPromise<void>;
duScrollTopAnimated(top: number): ng.IPromise<void>;
duScrollTopAnimated(top: number, duration: number, easing?: Function): ng.IPromise<void>;
duScrollLeft(left: number): void;
duScrollLeft(left: number, duration: number, easing?: Function): ng.IPromise<void>;
duScrollLeftAnimated(left: number): ng.IPromise<void>;
duScrollLeftAnimated(left: number, duration: number, easing?: Function): ng.IPromise<void>;
duScrollTop(): number;
duScrollLeft(): number;
}
}
+7 -4
View File
@@ -1,4 +1,4 @@
// Type definitions for Angular Translate (pascalprecht.translate module)
// Type definitions for Angular Translate v2.4.0 (pascalprecht.translate module)
// Project: https://github.com/PascalPrecht/angular-translate
// Definitions by: Michel Salib <https://github.com/michelsalib>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
@@ -42,7 +42,7 @@ declare module ng.translate {
instant(translationId: string, interpolateParams?: any, interpolationId?: string): string;
instant(translationId: string[], interpolateParams?: any, interpolationId?: string): { [key: string]: string };
isPostCompilingEnabled(): boolean;
preferredLanguage(): string;
preferredLanguage(langKey?: string): string;
proposedLanguage(): string;
refresh(langKey?: string): ng.IPromise<void>;
storage(): IStorage;
@@ -50,6 +50,8 @@ declare module ng.translate {
use(): string;
use(key: string): ng.IPromise<string>;
useFallbackLanguage(langKey?: string): void;
versionInfo(): string;
loaderCache(): any;
}
interface ITranslateProvider extends ng.IServiceProvider {
@@ -61,14 +63,14 @@ declare module ng.translate {
useMessageFormatInterpolation(): ITranslateProvider;
useInterpolation(factory: string): ITranslateProvider;
useSanitizeValueStrategy(value: string): ITranslateProvider;
preferredLanguage(): string;
preferredLanguage(): ITranslateProvider;
preferredLanguage(language: string): ITranslateProvider;
translationNotFoundIndicator(indicator: string): ITranslateProvider;
translationNotFoundIndicatorLeft(): string;
translationNotFoundIndicatorLeft(indicator: string): ITranslateProvider;
translationNotFoundIndicatorRight(): string;
translationNotFoundIndicatorRight(indicator: string): ITranslateProvider;
fallbackLanguage(): string;
fallbackLanguage(): ITranslateProvider;
fallbackLanguage(language: string): ITranslateProvider;
fallbackLanguage(languages: string[]): ITranslateProvider;
use(): string;
@@ -89,5 +91,6 @@ declare module ng.translate {
determinePreferredLanguage(fn?: () => void): ITranslateProvider;
registerAvailableLanguageKeys(): string[];
registerAvailableLanguageKeys(languageKeys: string[], aliases?: ILanguageKeyAlias): ITranslateProvider;
useLoaderCache(cache?: any): ITranslateProvider;
}
}
+14 -3
View File
@@ -13,11 +13,18 @@ myApp.config((
$urlMatcherFactory: ng.ui.IUrlMatcherFactory) => {
var matcher: ng.ui.IUrlMatcher = $urlMatcherFactory.compile("/foo/:bar?param1");
$urlMatcherFactory.type("myType2", {
encode: function (item: any) { return item; },
decode: function (item: any) { return item; },
is: function (item: any) { return true; }
});
var obj: Object = matcher.exec('/user/bob', { x:'1', q:'hello' });
var concat: ng.ui.IUrlMatcher = matcher.concat('/test');
var str: string = matcher.format({ id:'bob', q:'yes' });
var arr: string[] = matcher.parameters();
$urlRouterProvider
.when('/test', '/list')
.when('/test', '/list')
@@ -34,7 +41,11 @@ myApp.config((
$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "partials/state1.html"
templateUrl: "partials/state1.html",
params: {
param1: "defaultValue",
param2: undefined
}
})
.state('state1.list', {
url: "/list",
@@ -135,7 +146,7 @@ myApp.service("urlLocatorTest", UrlLocatorTestService);
module UiViewScrollProviderTests {
var app = angular.module("uiViewScrollProviderTests", ["ui.router"]);
app.config(['$uiViewScrollProvider', function($uiViewScrollProvider: ng.ui.IUiViewScrollProvider) {
// This prevents unwanted scrolling to the active nested state view.
// Use this when you have nested states, but you don't want the browser to scroll down the page
+4 -3
View File
@@ -17,7 +17,7 @@ declare module ng.ui {
controllerProvider?: any;
resolve?: {};
url?: string;
params?: any[];
params?: any;
views?: {};
abstract?: boolean;
onEnter?: any;
@@ -42,6 +42,7 @@ declare module ng.ui {
interface IUrlMatcherFactory {
compile(pattern: string): IUrlMatcher;
isMatcher(o: any): boolean;
type(name: string, definition: any, definitionFn?: any): any;
}
interface IUrlRouterProvider extends IServiceProvider {
@@ -108,10 +109,10 @@ declare module ng.ui {
*/
sync(): void;
}
interface IUiViewScrollProvider {
/*
* Reverts back to using the core $anchorScroll service for scrolling
* Reverts back to using the core $anchorScroll service for scrolling
* based on the url anchor.
*/
useAnchorScroll(): 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<FirebaseDataSnapshot>;
$transaction(key:string, updateFn: (currentData: any) => any, applyLocally?: boolean): ng.IPromise<FirebaseDataSnapshot>;
}
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>;
+98 -3
View File
@@ -1,6 +1,6 @@
// 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>
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="angular.d.ts" />
@@ -13,9 +13,104 @@ declare module ng.animate {
///////////////////////////////////////////////////////////////////////////
// AnimateService
// see http://docs.angularjs.org/api/ngAnimate.$animate
// see http://docs.angularjs.org/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
* @returns the animation callback promise
*/
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise<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
* @returns the animation callback promise
*/
leave(element: JQuery): ng.IPromise<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
* @returns the animation callback promise
*/
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise<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
* @returns the animation callback promise
*/
addClass(element: JQuery, className: string): ng.IPromise<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
* @returns the animation callback promise
*/
removeClass(element: JQuery, className: string): ng.IPromise<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
* @returns the animation callback promise
*/
setClass(element: JQuery, add: string, remove: string): ng.IPromise<void>;
/**
* Cancels the provided animation.
*/
cancel(animationPromise: ng.IPromise<void>): void;
}
///////////////////////////////////////////////////////////////////////////
// AngularProvider
// see http://docs.angularjs.org/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;
}
}
+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
+26 -7
View File
@@ -8,10 +8,29 @@
declare var $routeProvider: ng.route.IRouteProvider;
$routeProvider
.when('/projects/:projectId/dashboard',{
controller: '',
templateUrl: '',
caseInsensitiveMatch: true,
reloadOnSearch: false
})
.otherwise({redirectTo: '/'});
.when('/projects/:projectId/dashboard', {
controller: 'I am a string',
templateUrl: "So am I",
caseInsensitiveMatch: true,
reloadOnSearch: false
})
.when('/projects/:projectId/dashboard2', {
controller: function () {
//Look at me - I'm a function!
},
template: function ($routeParams?: ng.route.IRouteParamsService) {
return "I return a string"
}
})
.when('/projects/:projectId/dashboard3', {
controllerAs: 'I am a string',
template: "Yup. String"
})
.when('/projects/:projectId/dashboard4', {
controller: 'I am a string',
templateUrl: function ($routeParams?: ng.route.IRouteParamsService) {
return "I return a string"
}
})
.otherwise({ redirectTo: '/' })
.otherwise({ redirectTo: ($routeParams?: ng.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) => "" });
+6 -6
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
@@ -42,7 +42,7 @@ declare module ng.route {
* {(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;
controller?: string|Function;
/**
* A controller alias name. If present the controller will be published to scope under the controllerAs name.
*/
@@ -59,7 +59,7 @@ declare module ng.route {
*
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
*/
template?: string;
template?: string|{($routeParams?: ng.route.IRouteParamsService) : string;}
/**
* {string=|function()=}
* Path or function that returns a path to an html template that should be used by ngView.
@@ -68,14 +68,14 @@ declare module ng.route {
*
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
*/
templateUrl?: any;
templateUrl?: string|{ ($routeParams?: ng.route.IRouteParamsService): string; }
/**
* {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?: any;
resolve?: {[key: string]: any};
/**
* {(string|function())=}
* Value to update $location path with and trigger route redirection.
@@ -87,7 +87,7 @@ declare module ng.route {
* - {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;
redirectTo?: string|{($routeParams?: ng.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) : string};
/**
* Reload route when only $location.search() or $location.hash() changes.
*
+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
+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) {
+243 -118
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: {
@@ -237,7 +271,7 @@ declare module ng {
major: number;
minor: number;
dot: number;
codename: string;
codeName: string;
};
}
@@ -358,32 +392,44 @@ declare module ng {
// see http://docs.angularjs.org/api/ng.$compile.directive.Attributes
///////////////////////////////////////////////////////////////////////////
interface IAttributes {
// this is necessary to be able to access the scoped attributes. it's not very elegant
// because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way
// this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656
/**
* this is necessary to be able to access the scoped attributes. it's not very elegant
* because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way
* this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656
*/
[name: string]: any;
// Adds the CSS class value specified by the classVal parameter to the
// element. If animations are enabled then an animation will be triggered
// for the class addition.
/**
* Adds the CSS class value specified by the classVal parameter to the
* element. If animations are enabled then an animation will be triggered
* for the class addition.
*/
$addClass(classVal: string): void;
// Removes the CSS class value specified by the classVal parameter from the
// element. If animations are enabled then an animation will be triggered for
// the class removal.
/**
* Removes the CSS class value specified by the classVal parameter from the
* element. If animations are enabled then an animation will be triggered for
* the class removal.
*/
$removeClass(classVal: string): void;
// Set DOM element attribute value.
/**
* Set DOM element attribute value.
*/
$set(key: string, value: any): void;
// Observes an interpolated attribute.
// The observer function will be invoked once during the next $digest
// following compilation. The observer is then invoked whenever the
// interpolated value changes.
/**
* Observes an interpolated attribute.
* The observer function will be invoked once during the next $digest
* following compilation. The observer is then invoked whenever the
* interpolated value changes.
*/
$observe(name: string, fn: (value?: any) => any): Function;
// A map of DOM element attribute names to the normalized name. This is needed
// to do reverse lookup from normalized name back to actual name.
/**
* A map of DOM element attribute names to the normalized name. This is needed
* to do reverse lookup from normalized name back to actual name.
*/
$attr: Object;
}
@@ -412,6 +458,7 @@ declare module ng {
$commitViewValue(): void;
$rollbackViewValue(): void;
$setSubmitted(): void;
$setUntouched(): void;
}
///////////////////////////////////////////////////////////////////////////
@@ -423,12 +470,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;
@@ -447,6 +495,7 @@ declare module ng {
$validators: IModelValidators;
$asyncValidators: IAsyncModelValidators;
$pending: any;
$pristine: boolean;
$dirty: boolean;
$valid: boolean;
@@ -478,23 +527,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.
@@ -518,10 +575,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
@@ -529,9 +583,45 @@ declare module ng {
$$phase: any;
}
interface IScope extends IRootScopeService {
[index: string]: any;
}
interface IScope extends IRootScopeService { }
/**
* $scope for ngRepeat directive.
* see https://docs.angularjs.org/api/ng/directive/ngRepeat
*/
interface IRepeatScope extends IScope {
/**
* iterator offset of the repeated element (0..length-1).
*/
$index: number;
/**
* true if the repeated element is first in the iterator.
*/
$first: boolean;
/**
* true if the repeated element is between the first and last in the iterator.
*/
$middle: boolean;
/**
* true if the repeated element is last in the iterator.
*/
$last: boolean;
/**
* true if the iterator position $index is even (otherwise false).
*/
$even: boolean;
/**
* true if the iterator position $index is odd (otherwise false).
*/
$odd: boolean;
}
interface IAngularEvent {
/**
@@ -594,6 +684,35 @@ declare module ng {
cancel(promise: IPromise<any>): boolean;
}
///////////////////////////////////////////////////////////////////////////
// AngularProvider
// see http://docs.angularjs.org/api/ng/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: () => 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;
}
/**
* 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
@@ -670,11 +789,11 @@ 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
// We define this as separate interface so we can reopen it later for
// the ngMock module.
interface ILogCall {
(...args: any[]): void;
@@ -751,34 +870,12 @@ declare module ng {
* Change search part when called with parameter and return $location.
*
* @param search New search params
* @param paramValue If search is a string or a Number, then paramValue will override only a single search property. If paramValue is null, the property specified via the first argument will be deleted.
* @param paramValue If search is a string or a Number, then paramValue will override only a single search property. If paramValue is null, the property specified via the first argument will be deleted. If paramValue is an array, it will override the property of the search component of $location specified via the first argument. If paramValue is true, the property specified via the first argument will be added with no value nor trailing equal sign.
*/
search(search: string, paramValue: string): ILocationService;
/**
* Change search part when called with parameter and return $location.
*
* @param search New search params
* @param paramValue If search is a string or a Number, then paramValue will override only a single search property. If paramValue is null, the property specified via the first argument will be deleted.
*/
search(search: string, paramValue: number): ILocationService;
/**
* Change search part when called with parameter and return $location.
*
* @param search New search params
* @param paramValue If paramValue is an array, it will override the property of the search component of $location specified via the first argument.
*/
search(search: string, paramValue: string[]): ILocationService;
/**
* Change search part when called with parameter and return $location.
*
* @param search New search params
* @param paramValue If paramValue is true, the property specified via the first argument will be added with no value nor trailing equal sign.
*/
search(search: string, paramValue: boolean): ILocationService;
search(search: string, paramValue: string|number|string[]|boolean): ILocationService;
state(): any;
state(state: any): ILocationService;
url(): string;
url(url: string): ILocationService;
}
@@ -814,12 +911,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.
*
@@ -827,15 +932,7 @@ declare module ng {
*
* @param promises An array or hash of promises.
*/
all(promises: IPromise<any>[]): IPromise<any[]>;
/**
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
*
* Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
*
* @param promises An array or hash of promises.
*/
all(promises: { [id: string]: IPromise<any>; }): IPromise<{ [id: string]: any }>;
all(promises: IPromise<any>[]|{ [id: string]: IPromise<any>; }): IPromise<any[]>;
/**
* Creates a Deferred object which represents a task which will finish in the future.
*/
@@ -847,19 +944,13 @@ declare module ng {
*
* @param reason Constant, message, exception or an object representing the rejection reason.
*/
reject(reason?: any): IPromise<void>;
reject(reason?: any): IPromise<any>;
/**
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
*
* @param value Value or a promise
*/
when<T>(value: IPromise<T>): IPromise<T>;
/**
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
*
* @param value Value or a promise
*/
when<T>(value: T): IPromise<T>;
when<T>(value: IPromise<T>|T): IPromise<T>;
/**
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
*
@@ -874,32 +965,12 @@ declare module ng {
*
* This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method.
*/
then<TResult>(successCallback: (promiseValue: T) => IHttpPromise<TResult>, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
/**
* Regardless of when the promise was or will be resolved or rejected, then calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument: the result or rejection reason. Additionally, the notify callback may be called zero or more times to provide a progress indication, before the promise is resolved or rejected.
*
* This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method.
*/
then<TResult>(successCallback: (promiseValue: T) => IPromise<TResult>, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
/**
* Regardless of when the promise was or will be resolved or rejected, then calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument: the result or rejection reason. Additionally, the notify callback may be called zero or more times to provide a progress indication, before the promise is resolved or rejected.
*
* This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method.
*/
then<TResult>(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult, notifyCallback?: (state: any) => any): IPromise<TResult>;
then<TResult>(successCallback: (promiseValue: T) => IHttpPromise<TResult>|IPromise<TResult>|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
/**
* Shorthand for promise.then(null, errorCallback)
*/
catch<TResult>(onRejected: (reason: any) => IHttpPromise<TResult>): IPromise<TResult>;
/**
* Shorthand for promise.then(null, errorCallback)
*/
catch<TResult>(onRejected: (reason: any) => IPromise<TResult>): IPromise<TResult>;
/**
* Shorthand for promise.then(null, errorCallback)
*/
catch<TResult>(onRejected: (reason: any) => TResult): IPromise<TResult>;
catch<TResult>(onRejected: (reason: any) => IHttpPromise<TResult>|IPromise<TResult>|TResult): IPromise<TResult>;
/**
* Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful to release resources or do some clean-up that needs to be done whether the promise was rejected or resolved. See the full specification for more information.
@@ -922,6 +993,7 @@ declare module ng {
///////////////////////////////////////////////////////////////////////////
interface IAnchorScrollService {
(): void;
yOffset: any;
}
interface IAnchorScrollProvider extends IServiceProvider {
@@ -981,6 +1053,8 @@ declare module ng {
imgSrcSanitizationWhitelist(): RegExp;
imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider;
debugInfoEnabled(enabled?: boolean): any;
}
interface ICloneAttachFunction {
@@ -1015,6 +1089,7 @@ declare module ng {
interface IControllerProvider extends IServiceProvider {
register(name: string, controllerConstructor: Function): void;
register(name: string, dependencyAnnotatedConstructor: any[]): void;
allowGlobals(): void;
}
/**
@@ -1170,8 +1245,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> {
@@ -1185,14 +1265,30 @@ declare module ng {
interface IHttpPromise<T> extends IPromise<T> {
success(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
error(callback: IHttpPromiseCallback<any>): IHttpPromise<T>;
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => IPromise<TResult>, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => IPromise<TResult>|TResult, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
}
/**
* Object that controls the defaults for $http provider
* https://docs.angularjs.org/api/ng/service/$http#defaults
*/
interface IHttpProviderDefaults {
xsrfCookieName?: string;
xsrfHeaderName?: string;
withCredentials?: boolean;
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;
}
///////////////////////////////////////////////////////////////////////////
@@ -1211,7 +1307,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;
}
@@ -1286,6 +1382,34 @@ declare module ng {
resourceUrlWhitelist(whitelist: any[]): void;
}
/**
* $templateRequest service
* see http://docs.angularjs.org/api/ng/service/$templateRequest
*/
interface ITemplateRequestService {
/**
* Downloads a template using $http and, upon success, stores the
* contents inside of $templateCache.
*
* If the HTTP request fails or the response data of the HTTP request is
* empty then a $compile error will be thrown (unless
* {ignoreRequestError} is set to true).
*
* @param tpl The template URL.
* @param ignoreRequestError Whether or not to ignore the exception
* when the request fails or the template is
* empty.
*
* @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;
}
///////////////////////////////////////////////////////////////////////////
// Directive
// see http://docs.angularjs.org/api/ng.$compileProvider#directive
@@ -1303,7 +1427,7 @@ declare module ng {
instanceAttributes: IAttributes,
controller: any,
transclude: ITranscludeFunction
): void;
): void;
}
interface IDirectivePrePost {
@@ -1316,13 +1440,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;
@@ -1360,7 +1485,7 @@ declare module ng {
find(selector: string): IAugmentedJQuery;
find(element: any): IAugmentedJQuery;
find(obj: JQuery): IAugmentedJQuery;
controller(): any;
controller(name: string): any;
injector(): any;
scope(): IScope;
+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;
+9
View File
@@ -0,0 +1,9 @@
/// <reference path="animation-frame.d.ts"/>
module AnimationFrameTests {
var animation = new AnimationFrame();
function frame() {
animation.request(frame);
}
animation.request(frame);
}
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for animation-frame 0.1.7
// Project: https://github.com/kof/animation-frame
// Definitions by: Qinfeng Chen <https://github.com/qinfchen>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface AnimationFrame {
new(): AnimationFrame;
request(callback: () => void): void;
}
declare var AnimationFrame: AnimationFrame;
@@ -0,0 +1,29 @@
/// <reference path="../any-db/any-db.d.ts" />
/// <reference path="any-db-transaction.d.ts" />
"use strict";
import anyDB = require("any-db");
import begin = require("any-db-transaction");
var conn: anyDB.Connection = anyDB.createConnection("mysql://user:password@localhost/testdb");
var transaction = begin(conn);
var transaction2 = begin(transaction);
begin(conn, { autoRollback: true });
begin(conn, (error: Error, result: begin.Transaction): void => {
});
transaction.query("SELECT * FROM MyTable");
transaction.commit();
transaction.commit((error: Error): void => {
});
transaction.rollback();
transaction.rollback((error: Error): void => {
});
+94
View File
@@ -0,0 +1,94 @@
// Type definitions for any-db-transaction 2.2.1
// Project: https://github.com/grncdr/node-any-db-transaction
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
/// <reference path="../any-db/any-db.d.ts" />
declare module "any-db-transaction" {
import anyDB = require("any-db");
module begin {
/**
* Transaction objects are are simple wrappers around a Connection that also implement the Queryable API,
* but guarantee that all queries take place within a single database transaction or not at all. Note that
* begin also understands how to acquire (and release) a connection from a ConnectionPool as well, so you
* can simply pass a pool to it: var tx = begin(pool)
*
* By default, any queries that error during a transaction will cause an automatic rollback. If a query has
* no callback, the transaction will also handle (and re-emit) 'error' events for the Query instance.
* This enables handling errors for an entire transaction in a single place.
*
* Transactions may also be nested by passing a Transaction to begin and these nested transactions can
* safely error and rollback without rolling back their parent transaction
*
* Transaction events:
* 'query', query - emitted immediately after .query is called on a connection via tx.query. The argument is a query object.
* 'commit:start' - Emitted when .commit() is called.
* 'commit:complete' - Emitted after the transaction has committed.
* 'rollback:start' - Emitted when .rollback() is called.
* 'rollback:complete' - Emitted after the transaction has rolled back.
* 'close' - Emitted after rollback or commit completes.
* 'error', err - Emitted under three conditions:
* There was an error acquiring a connection.
* Any query performed in this transaction emits an error that would otherwise go unhandled.
* Any of query, begin, commit, or rollback are called after the connection has already been committed or rolled back.
* Note that the 'error' event may be emitted multiple times! depending on the callback you are registering, you way want to wrap it using [once][].
*/
interface Transaction extends anyDB.Queryable {
/**
* Issue a COMMIT (or RELEASE ... in the case of nested transactions) statement to the database.
* If a continuation is provided it will be called (possibly with an error) after the COMMIT
* statement completes. The transaction object itself will be unusable after calling commit().
*/
commit(callback?: (error: Error) => void): void;
/**
* The same as Transaction.commit but issues a ROLLBACK. Again, the transaction will be unusable after calling this method.
*/
rollback(callback?: (error: Error) => void): void;
}
interface TransactionOptions {
/**
* Adapter name e.g. 'mysql'
*/
adapter?: anyDB.Adapter;
/**
* SQL statement for beginning a transaction, default 'BEGIN'
*/
begin?: string;
/**
* SQL statement for committing a transaction, default 'COMMIT'
*/
commit?: string;
/**
* SQL statement for rolling back a transaction, default 'ROLLBACK'
*/
rollback?: string;
/**
* Callback for transaction
*/
callback?: (error: Error, transaction: Transaction) => void;
/**
* Rollback automatically on error, default true
*/
autoRollback?: boolean;
}
}
/**
* Start a transaction
*/
function begin(q: anyDB.Queryable, options?: begin.TransactionOptions, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
function begin(q: anyDB.Queryable, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
function begin(q: anyDB.Queryable, beginStatement?: string, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
function begin(q: anyDB.Queryable, options?: begin.TransactionOptions, beginStatement?: string, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
export = begin;
}
+38
View File
@@ -0,0 +1,38 @@
/// <reference path="any-db.d.ts" />
"use strict";
import anyDB = require("any-db");
var conn: anyDB.Connection = anyDB.createConnection("mysql://user:password@localhost/testdb");
var sql: string = "SELECT * FROM questions";
conn.query(sql, [1, "boo"]);
conn.query(sql).on("data", (row: Object[]): void => {
// nothing
});
conn.query(sql, [1, "s"], (error: Error, result: anyDB.ResultSet): void => {
result.rows.length;
result.fields.length;
});
conn.end();
var poolConfig: anyDB.PoolConfig = {
min: 1,
max: 200
};
var pool: anyDB.ConnectionPool = anyDB.createPool("mysql://user:password@localhost/testdb", poolConfig);
pool.query(sql).on("data", (row: Object[]): void => {
// nothing
});
pool.close((error: Error): void => {
});
+303
View File
@@ -0,0 +1,303 @@
// Type definitions for any-db 2.1.0
// Project: https://github.com/grncdr/node-any-db
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module "any-db" {
import events = require("events");
import stream = require("stream");
export interface ConnectOpts {
adapter: string;
}
export interface Adapter {
name: string;
/**
* Create a new connection object. In common usage, config will be created by parse-db-url and passed to the adapter by any-db.
* If a continuation is given, it must be called, either with an error or the established connection.
*/
createConnection(opts: ConnectOpts, callback?: (error: Error, result: Connection) => void): Connection;
/**
* Create a Query that may eventually be executed later on by a Connection. While this function is rarely needed by user code,
* it makes it possible for ConnectionPool.query and Transaction.query to fulfill the Queryable.query contract
* by synchronously returning a Query stream
*/
createQuery(text: string, params?: any[], callback?: (error: Error, result: ResultSet) => void): Query;
createQuery(query: Query): Query;
}
/**
* Other properties are driver specific
*/
export interface Field {
name: string;
}
/**
* ResultSet objects are just plain data that collect results of a query when a continuation
* is provided to Queryable.query. The lastInsertId is optional, and currently supported by
* sqlite3 and mysql but not postgres, because it is not supported by Postgres itself.
*/
export interface ResultSet {
/**
* Affected rows. Note e.g. for INSERT queries the rows property is not filled even
* though rowCount is non-zero.
*/
rowCount: number;
/**
* Result rows
*/
rows: Object[];
/**
* Result field descriptions
*/
fields: Field[];
/**
* Not supported by all drivers.
*/
fieldCount?: number;
/**
* Not supported by all drivers.
*/
lastInsertId?: any;
/**
* Not supported by all drivers.
*/
affectedRows?: number;
/**
* Not supported by all drivers.
*/
changedRows?: number;
}
/**
* Query objects are returned by the Queryable.query method, available on connections,
* pools, and transactions. Queries are instances of Readable, and as such can be piped
* through transforms and support backpressure for more efficient memory-usage on very
* large results sets. (Note: at this time the sqlite3 driver does not support backpressure)
*
* Internally, Query instances are created by a database Adapter and may have more methods,
* properties, and events than are described here. Consult the documentation for your
* specific adapter to find out about any extensions.
*
* Events:
*
* Error event
* The 'error' event is emitted at most once per query. Note that this event will be
* emitted for errors even if a callback was provided, the callback will
* simply be subscribed to the 'error' event.
* One argument is passed to event listeners:
* error - the error object.
*
* Fields event
* A 'fields' event is emmitted before any 'data' events.
* One argument is passed to event listeners:
* fields - an array of [Field][ResultSet] objects.
*
* The following events are part of the stream.Readable interface which is implemented by Query:
*
* Data event
* A 'data' event is emitted for each row in the query result set.
* One argument is passed to event listeners:
* row contains the contents of a single row in the query result
*
* Close event
* A 'close' event is emitted when the query completes.
* No arguments are passed to event listeners.
*
* End event
* An 'end' event is emitted after all query results have been consumed.
* No arguments are passed to event listeners.
*/
export interface Query extends stream.Readable {
/**
* The SQL query as a string. If you are using MySQL this will contain
* interpolated values after the query has been enqueued by a connection.
*/
text: string;
/**
* The array of parameter values.
*/
values: any[];
/**
* The callback (if any) that was provided to Queryable.query. Note that
* Query objects must not use a closed over reference to their callback,
* as other any-db libraries may rely on modifying the callback property
* of a Query they did not create.
*/
callback: (error: Error, results: ResultSet) => void;
}
/**
* Events:
* The 'query' event is emitted immediately before a query is executed. One argument is passed to event handlers:
* - query: a Query object
*/
export interface Queryable extends events.EventEmitter {
/**
* The Adapter instance that will be used by this Queryable for creating Query instances and/or connections.
*/
adapter: Adapter;
/**
* Execute a SQL statement using bound parameters (if they are provided) and return a Query object
* that is a Readable stream of the resulting rows. If a Continuation<ResultSet> is provided the rows
* returned by the database will be aggregated into a [ResultSet][] which will be passed to the
* continuation after the query has completed.
* The second form is not needed for normal use, but must be implemented by adapters to work correctly
* with ConnectionPool and Transaction. See Adapter.createQuery for more details.
*/
query(text: string, params?: any[], callback?: (error: Error, results: ResultSet) => void): Query
/**
* The second form is not needed for normal use, but must be implemented by adapters to work correctly
* with ConnectionPool and Transaction. See Adapter.createQuery for more details.
*/
// query(query: Query): Query;
}
/**
* Connection objects are obtained using createConnection from Any-DB or ConnectionPool.acquire,
* both of which delegate to the createConnection implementation of the specified adapter.
* While all Connection objects implement the Queryable interface, the implementations in
* each adapter may add additional methods or emit additional events. If you need to access a
* feature of your database that is not described here (such as Postgres' server-side prepared
* statements), consult the documentation for your adapter.
*
* Events:
* Error event
* The 'error' event is emitted when there is a connection-level error.
* No arguments are passed to event listeners.
*
* Open event
* The 'open' event is emitted when the connection has been established and is ready to query.
* No arguments are passed to event listeners.
*
* Close event
* The 'close' event is emitted when the connection has been closed.
* No arguments are passed to event listeners.
*/
export interface Connection extends Queryable {
/**
* Close the database connection. If a continuation is provided it
* will be called after the connection has closed.
*/
end(callback?: (error: Error) => void): void;
}
export interface ConnectionStatic {
new(): Connection;
name: string;
createConnection(): void;
createPool(): void;
}
/**
* ConnectionPool events
* 'acquire' - emitted whenever pool.acquire is called
* 'release' - emitted whenever pool.release is called
* 'query', query - emitted immediately after .query is called on a
* connection via pool.query. The argument is a Query object.
* 'close' - emitted when the connection pool has closed all of it
* connections after a call to close().
*/
export interface ConnectionPool extends Queryable {
/**
* Implements Queryable.query by automatically acquiring a connection
* and releasing it when the query completes.
*/
query(text: string, params?: any[], callback?: (error: Error, results: ResultSet) => void): Query;
/**
* Remove a connection from the pool. If you use this method you must
* return the connection back to the pool using ConnectionPool.release
*/
acquire(callback: (error: Error, result: Connection) => void): void;
/**
* Return a connection to the pool. This should only be called with connections
* you've manually acquired. You must not continue to use the connection after releasing it.
*/
release(connection: Connection): void;
/**
* Stop giving out new connections, and close all existing database connections as they
* are returned to the pool.
*/
close(callback?: (error: Error) => void): void;
}
/**
* A PoolConfig is generally a plain object with any of the following properties (they are all optional):
*/
export interface PoolConfig {
/**
* min (default 0) The minimum number of connections to keep open in the pool.
*/
min?: number;
/**
* max (default 10) The maximum number of connections to keep open in the pool.
* When this limit is reached further requests for connections will queue waiting
* for an existing connection to be released back into the pool.
*/
max?: number;
/**
* (default 30000) The maximum amount of time a connection can sit idle in the pool before being reaped
*/
idleTimeout?: number;
/**
* (default 1000) How frequently the pool should check for connections that are old enough to be reaped.
*/
reapInterval?: number;
/**
* (default true) When this is true, the pool will reap connections that
* have been idle for more than idleTimeout milliseconds.
*/
refreshIdle?: boolean;
/**
* Called immediately after a connection is first established. Use this to do one-time setup of new connections.
* The supplied Connection will not be added to the pool until you pass it to the done continuation.
*/
onConnect?: (connection: Connection, ready: (error: Error, result: Connection) => void) => void;
/**
* Called each time a connection is returned to the pool. Use this to restore a connection to
* it's original state (e.g. rollback transactions, set the database session vars). If reset
* fails to call the done continuation the connection will be lost in limbo.
*/
reset?: (connection: Connection, done: (error: Error) => void) => void;
/**
* (default function (err) { return true }) - Called when an error is encountered
* by pool.query or emitted by an idle connection. If shouldDestroyConnection(error)
* is truthy the connection will be destroyed, otherwise it will be reset.
*/
shouldDestroyConnection?: (error: Error) => boolean;
}
/**
* Create a database connection.
* @param url String of the form adapter://user:password@host/database
* @param callback
* @returns Connection object.
*/
export function createConnection(url: string, callback?: (error: Error, connection: Connection) => void): Connection;
/**
* Create a database connection.
* @param opts Object with adapter name and any properties that the given adapter requires
* @param callback
* @returns Connection object.
*/
export function createConnection(opts: ConnectOpts, callback?: (error: Error, connection: Connection) => void): Connection;
export function createPool(url: string, config: PoolConfig): ConnectionPool;
export function createPool(opts: ConnectOpts, config: PoolConfig): ConnectionPool;
}
+32
View File
@@ -0,0 +1,32 @@
/// <reference path="./archy.d.ts" />
import archy = require("archy");
var opts: archy.Options = {
};
var data: archy.Data = {
label: 'beep',
nodes: [
'ity',
{
label: 'boop',
nodes: [
{
label: 'o_O',
nodes: [
{
label: 'oh',
nodes: ['hello', 'puny']
},
'human'
]
},
'party\ntime!'
]
}
]
};
var str = archy(data);
console.log(str);
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for archy
// Project: https://github.com/substack/node-archy
// Definitions by: vvakame <https://github.com/vvakame/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "archy" {
function archy(obj: archy.Data, prefix?: string, opts?: archy.Options): string;
function archy(obj: string, prefix?: string, opts?: archy.Options): string;
module archy {
interface Data {
label: string;
nodes?: (Data | string)[];
}
interface Options {
unicode?: boolean;
}
}
export = archy;
}
@@ -0,0 +1,21 @@
/// <reference path="aspnet-identity-pw.d.ts" />
import passwordHasher = require('aspnet-identity-pw');
function usageSync() {
var hashedPassword: string = passwordHasher.hashPassword('SomePassword');
var isValid: boolean = passwordHasher.validatePassword('SomePassword', hashedPassword);
}
function usageAsync() {
var hashedPassword: string = null;
var isValid: boolean = null;
passwordHasher.hashPassword('SomePassword', function(err, result) {
hashedPassword = result;
});
passwordHasher.validatePassword('SomePassword', hashedPassword, function(err, result) {
isValid = result;
});
}
+13
View File
@@ -0,0 +1,13 @@
// Type definitions for aspnet-identity-pw 1.0.0
// Project: https://github.com/Syncbak-Git/aspnet-identity-pw
// Definitions by: jt000 <https://github.com/jt000>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module "aspnet-identity-pw" {
export function hashPassword(password: string): string;
export function hashPassword(password: string, callback: (err: any, result: string)=>void): void;
export function validatePassword(password: string, hashedPass: string): boolean;
export function validatePassword(password: string, hashedPass: string, callback: (err: any, result: boolean) => void): void;
}
+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
+44
View File
@@ -0,0 +1,44 @@
/// <reference path="async.d.ts" />
interface StringCallback { (err: Error, result: string): void; }
interface AsyncStringGetter { (callback: StringCallback): void; }
var taskArray: AsyncStringGetter[] = [
function (callback) {
setTimeout(function () {
callback(null, 'one');
}, 200);
},
function (callback) {
setTimeout(function () {
callback(null, 'two');
}, 100);
},
];
async.series(taskArray, function (err, results) { console.log(results[0].match(/o/)) });
async.parallel(taskArray, function (err, results) { console.log(results[0].match(/o/)) });
async.parallelLimit(taskArray, 3, function (err, results) { console.log(results[0].match(/o/)) });
interface Lookup<T> { [key: string]: T; }
interface NumberCallback { (err: Error, result: number): void; }
interface AsyncNumberGetter { (callback: NumberCallback): void; }
var taskDict: Lookup<AsyncNumberGetter> = {
one: function(callback){
setTimeout(function(){
callback(null, 1);
}, 200);
},
two: function(callback){
setTimeout(function(){
callback(null, 2);
}, 100);
}
}
async.series(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) });
async.parallel(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) });
async.parallelLimit(taskDict, 3, function(err, results) { console.log(results['one'].toFixed(1)) });
+1
View File
@@ -0,0 +1 @@
--noImplicitAny
+64 -10
View File
@@ -67,6 +67,17 @@ async.series([
],
function (err, results) { });
async.series<string>([
function (callback) {
callback(null, 'one');
},
function (callback) {
callback(null, 'two');
},
],
function (err, results) { });
async.series({
one: function (callback) {
setTimeout(function () {
@@ -81,6 +92,21 @@ async.series({
},
function (err, results) { });
async.series<number>({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
}, 200);
},
two: function (callback) {
setTimeout(function () {
callback(null, 2);
}, 100);
},
},
function (err, results) { });
async.parallel([
function (callback) {
setTimeout(function () {
@@ -95,6 +121,20 @@ async.parallel([
],
function (err, results) { });
async.parallel<string>([
function (callback) {
setTimeout(function () {
callback(null, 'one');
}, 200);
},
function (callback) {
setTimeout(function () {
callback(null, 'two');
}, 100);
},
],
function (err, results) { });
async.parallel({
one: function (callback) {
@@ -110,6 +150,20 @@ async.parallel({
},
function (err, results) { });
async.parallel<number>({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
}, 200);
},
two: function (callback) {
setTimeout(function () {
callback(null, 2);
}, 100);
},
},
function (err, results) { });
var count = 0;
@@ -136,7 +190,7 @@ async.waterfall([
], function (err, result) { });
var q = async.queue(function (task: any, callback) {
var q = async.queue<any>(function (task: any, callback) {
console.log('hello ' + task.name);
callback();
}, 2);
@@ -189,29 +243,29 @@ q.resume();
q.kill();
// tests for strongly typed tasks
var q2 = async.queue(function (task: string, callback) {
var q2 = async.queue<string>(function (task: string, callback) {
console.log('Task: ' + task);
callback();
}, 1);
q2.push('task1');
q2.push('task2', function (error, results: string[]) {
console.log('Finished tasks: ' + results.join(', '));
q2.push('task2', function (error) {
console.log('Finished tasks');
});
q2.push(['task3', 'task4', 'task5'], function (error, results: string[]) {
console.log('Finished tasks: ' + results.join(', '));
q2.push(['task3', 'task4', 'task5'], function (error) {
console.log('Finished tasks');
});
q2.unshift('task1');
q2.unshift('task2', function (error, results: string[]) {
console.log('Finished tasks: ' + results.join(', '));
q2.unshift('task2', function (error) {
console.log('Finished tasks');
});
q2.unshift(['task3', 'task4', 'task5'], function (error, results: string[]) {
console.log('Finished tasks: ' + results.join(', '));
q2.unshift(['task3', 'task4', 'task5'], function (error) {
console.log('Finished tasks');
});
var filename = '';
+76 -49
View File
@@ -3,24 +3,49 @@
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface AsyncMultipleResultsCallback<T> { (err: Error, results: T[]): any; }
interface AsyncSingleResultCallback<T> { (err: Error, result: T): void; }
interface AsyncTimesCallback<T> { (n: number, callback: AsyncMultipleResultsCallback<T>): void; }
interface Dictionary<T> { [key: string]: T; }
interface AsyncIterator<T, R> { (item: T, callback: AsyncSingleResultCallback<R>): void; }
interface AsyncMemoIterator<T, R> { (memo: R, item: T, callback: AsyncSingleResultCallback<R>): void; }
interface ErrorCallback { (err?: Error): void; }
interface AsyncResultCallback<T> { (err: Error, result: T): void; }
interface AsyncResultArrayCallback<T> { (err: Error, results: T[]): void; }
interface AsyncResultObjectCallback<T> { (err: Error, results: Dictionary<T>): void; }
interface AsyncTimesCallback<T> { (n: number, callback: AsyncResultArrayCallback<T>): void; }
interface AsyncWorker<T> { (task: T, callback: Function): void; }
interface AsyncIterator<T> { (item: T, callback: ErrorCallback): void; }
interface AsyncResultIterator<T, R> { (item: T, callback: AsyncResultCallback<R>): void; }
interface AsyncMemoIterator<T, R> { (memo: R, item: T, callback: AsyncResultCallback<R>): void; }
interface AsyncWorker<T> { (task: T, callback: ErrorCallback): void; }
interface AsyncFunction<T> { (callback: AsyncResultCallback<T>): void; }
interface AsyncVoidFunction { (callback: ErrorCallback): void; }
interface AsyncQueue<T> {
length(): number;
concurrency: number;
started: boolean;
paused: boolean;
push(task: T, callback?: AsyncMultipleResultsCallback<T>): void;
push(task: T[], callback?: AsyncMultipleResultsCallback<T>): void;
unshift(task: T, callback?: AsyncMultipleResultsCallback<T>): void;
unshift(task: T[], callback?: AsyncMultipleResultsCallback<T>): void;
push(task: T, callback?: ErrorCallback): void;
push(task: T[], callback?: ErrorCallback): void;
unshift(task: T, callback?: ErrorCallback): void;
unshift(task: T[], callback?: ErrorCallback): void;
saturated: () => any;
empty: () => any;
drain: () => any;
running(): number;
idle(): boolean;
pause(): void;
resume(): void;
kill(): void;
}
interface AsyncPriorityQueue<T> {
length(): number;
concurrency: number;
started: boolean;
paused: boolean;
push(task: T, priority: number, callback?: AsyncResultArrayCallback<T>): void;
push(task: T[], priority: number, callback?: AsyncResultArrayCallback<T>): void;
saturated: () => any;
empty: () => any;
drain: () => any;
@@ -34,49 +59,51 @@ interface AsyncQueue<T> {
interface Async {
// Collections
each<T,R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): void;
eachSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): void;
eachLimit<T, R>(arr: T[], limit: number, iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): void;
map<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): any;
mapSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): any;
filter<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
select<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
filterSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
selectSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
reject<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
rejectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
detect<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
detectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
sortBy<T, V>(arr: T[], iterator: AsyncIterator<T, V>, callback: AsyncMultipleResultsCallback<T>): any;
some<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
any<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
every<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any): any;
all<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any): any;
concat<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>): any;
concatSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>): any;
each<T>(arr: T[], iterator: AsyncIterator<T>, callback: ErrorCallback): void;
eachSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback: ErrorCallback): void;
eachLimit<T>(arr: T[], limit: number, iterator: AsyncIterator<T>, callback: ErrorCallback): void;
map<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback: AsyncResultArrayCallback<R>): any;
mapSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback: AsyncResultArrayCallback<R>): any;
mapLimit<T, R>(arr: T[], limit: number, iterator: AsyncResultIterator<T, R>, callback: AsyncResultArrayCallback<R>): any;
filter<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
select<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
filterSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
selectSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
reject<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
rejectSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (results: T[]) => any): any;
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
detect<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: AsyncResultArrayCallback<T>): any;
detectSeries<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: AsyncResultArrayCallback<T>): any;
sortBy<T, V>(arr: T[], iterator: AsyncResultIterator<T, V>, callback: AsyncResultArrayCallback<T>): any;
some<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: AsyncResultArrayCallback<T>): any;
any<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: AsyncResultArrayCallback<T>): any;
every<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (result: boolean) => any): any;
all<T>(arr: T[], iterator: AsyncResultIterator<T, boolean>, callback: (result: boolean) => any): any;
concat<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback: AsyncResultArrayCallback<R>): any;
concatSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback: AsyncResultArrayCallback<R>): any;
// Control Flow
series<T>(tasks: T[], callback?: AsyncMultipleResultsCallback<T>): void;
series<T>(tasks: T, callback?: AsyncMultipleResultsCallback<T>): void;
parallel<T>(tasks: T[], callback?: AsyncMultipleResultsCallback<T>): void;
parallel<T>(tasks: T, callback?: AsyncMultipleResultsCallback<T>): void;
parallelLimit<T>(tasks: T[], limit: number, callback?: AsyncMultipleResultsCallback<T>): void;
parallelLimit<T>(tasks: T, limit: number, callback?: AsyncMultipleResultsCallback<T>): void;
whilst(test: Function, fn: Function, callback: Function): void;
until(test: Function, fn: Function, callback: Function): void;
waterfall<T>(tasks: T[], callback?: AsyncMultipleResultsCallback<T>): void;
waterfall<T>(tasks: T, callback?: AsyncMultipleResultsCallback<T>): void;
series<T>(tasks: Array<AsyncFunction<T>>, callback?: AsyncResultArrayCallback<T>): void;
series<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void;
parallel<T>(tasks: Array<AsyncFunction<T>>, callback?: AsyncResultArrayCallback<T>): void;
parallel<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void;
parallelLimit<T>(tasks: Array<AsyncFunction<T>>, limit: number, callback?: AsyncResultArrayCallback<T>): void;
parallelLimit<T>(tasks: Dictionary<AsyncFunction<T>>, limit: number, callback?: AsyncResultObjectCallback<T>): void;
whilst(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void;
doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void;
until(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void;
doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void;
waterfall(tasks: Function[], callback?: AsyncResultArrayCallback<any>): void;
queue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncQueue<T>;
// auto(tasks: any[], callback?: AsyncMultipleResultsCallback<T>): void;
auto(tasks: any, callback?: AsyncMultipleResultsCallback<any>): void;
priorityQueue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncPriorityQueue<T>;
auto(tasks: any, callback?: AsyncResultArrayCallback<any>): void;
iterator(tasks: Function[]): Function;
apply(fn: Function, ...arguments: any[]): void;
nextTick<T>(callback: Function): void;
apply(fn: Function, ...arguments: any[]): AsyncFunction<any>;
nextTick(callback: Function): void;
times<T> (n: number, callback: AsyncTimesCallback<T>): void;
timesSeries<T> (n: number, callback: AsyncTimesCallback<T>): void;

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