diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 6140babecd..4317128869 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -695,7 +695,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](heap/heap.d.ts) [heap](https://github.com/qiao/heap.js) by [Ryan McNamara](https://github.com/ryan10132)
* [:link:](heatmap.js/heatmap.d.ts) [heatmap.js](https://github.com/pa7/heatmap.js) by [Yang Guan](https://github.com/lookuptable)
* [:link:](hellojs/hellojs.d.ts) [hello.js](http://adodson.com/hello.js) by [Pavel Zika](https://github.com/PavelPZ)
-* [:link:](helmet/helmet.d.ts) [helmet](https://github.com/helmetjs/helmet) by [Cyril Schumacher](https://github.com/cyrilschumacher)
+* [:link:](helmet/helmet.d.ts) [helmet](https://github.com/helmetjs/helmet) by [Cyril Schumacher](https://github.com/cyrilschumacher), [Evan Hahn](https://github.com/EvanHahn)
* [:link:](highcharts/highcharts.d.ts) [Highcharts](http://www.highcharts.com) by [Damiano Gambarotto](http://github.com/damianog), [Dan Lewi Harkestad](http://github.com/baltie)
* [:link:](highcharts-ng/highcharts-ng.d.ts) [highcharts-ng](https://github.com/pablojim/highcharts-ng) by [Scott Hatcher](https://github.com/scatcher)
* [:link:](highland/highland.d.ts) [Highland](http://highlandjs.org) by [Bart van der Schoor](https://github.com/Bartvds)
diff --git a/CybozuLabs-md5/CybozuLabs-md5-tests.ts b/CybozuLabs-md5/CybozuLabs-md5-tests.ts
new file mode 100644
index 0000000000..16dd05b059
--- /dev/null
+++ b/CybozuLabs-md5/CybozuLabs-md5-tests.ts
@@ -0,0 +1,9 @@
+///
+
+var hash: string;
+hash = CybozuLabs.MD5.calc("abc");
+hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_ASCII);
+hash = CybozuLabs.MD5.calc("abc", CybozuLabs.MD5.BY_UTF16);
+
+var version: string;
+version = CybozuLabs.MD5.VERSION;
\ No newline at end of file
diff --git a/CybozuLabs-md5/CybozuLabs-md5.d.ts b/CybozuLabs-md5/CybozuLabs-md5.d.ts
new file mode 100644
index 0000000000..6e1f31739d
--- /dev/null
+++ b/CybozuLabs-md5/CybozuLabs-md5.d.ts
@@ -0,0 +1,11 @@
+// Type definitions for CybozuLabs.MD5
+// Project: http://labs.cybozu.co.jp/blog/mitsunari/2007/07/md5js_1.html
+// Definitions by: MIZUNE Pine
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare namespace CybozuLabs.MD5 {
+ var VERSION: string;
+ var BY_ASCII: number;
+ var BY_UTF16: number;
+ function calc(str: string, option?: number): string;
+}
diff --git a/README.md b/README.md
index 5c218aaa19..279be10799 100644
--- a/README.md
+++ b/README.md
@@ -32,7 +32,7 @@ Please see the [contribution guide](http://definitelytyped.org/guides/contributi
## Requested definitions
-Here is are the [currently requested definitions](https://github.com/DefinitelyTyped/DefinitelyTyped/labels/Definition%3ARequest).
+Here are the [currently requested definitions](https://github.com/DefinitelyTyped/DefinitelyTyped/labels/Definition%3ARequest).
## License
diff --git a/adal-angular/adal-tests.ts b/adal-angular/adal-tests.ts
index 598134d0a0..3b9e46c961 100644
--- a/adal-angular/adal-tests.ts
+++ b/adal-angular/adal-tests.ts
@@ -12,4 +12,12 @@ var config : adal.Config = {
var auth = new AuthenticationContext(config);
+Logging.log = (message: string) => {
+ console.log(message);
+}
+
+Logging.level = 4;
+
+auth.info("Logging message");
+
var userName: string = auth.getCachedUser().userName;
\ No newline at end of file
diff --git a/adal-angular/adal.d.ts b/adal-angular/adal.d.ts
index c5a64efd0b..76b86e7150 100644
--- a/adal-angular/adal.d.ts
+++ b/adal-angular/adal.d.ts
@@ -4,9 +4,10 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var AuthenticationContext: adal.AuthenticationContextStatic;
+declare var Logging: adal.Logging;
declare module 'adal' {
- export = AuthenticationContext;
+ export = { AuthenticationContext, Logging };
}
declare namespace adal {
@@ -36,6 +37,18 @@ declare namespace adal {
stateResponse: string,
requestType: string
}
+
+ interface Logging {
+ log: (message: string) => void;
+ level: LoggingLevel;
+ }
+
+ enum LoggingLevel {
+ ERROR = 0,
+ WARNING = 1,
+ INFO = 2,
+ VERBOSE = 3
+ }
interface AuthenticationContextStatic {
new (config: Config): AuthenticationContext;
diff --git a/angular-local-storage/angular-local-storage.d.ts b/angular-local-storage/angular-local-storage.d.ts
index b2bcf377d2..7efc681491 100644
--- a/angular-local-storage/angular-local-storage.d.ts
+++ b/angular-local-storage/angular-local-storage.d.ts
@@ -56,6 +56,15 @@ declare namespace angular.local.storage {
* @param val
*/
set(key:string, val:string):boolean;
+ /**
+ * Directly adds a value to cookies with an expiration.
+ * Note: Typically used as a fallback if local storage is not supported.
+ * Returns: Boolean
+ * @param key
+ * @param val
+ * @param daysToExpiry
+ */
+ set(key:string, val:string, daysToExpiry:number):boolean;
/**
* Directly get a value from a cookie.
* Returns: value from local storage
diff --git a/angular-material/angular-material-tests.ts b/angular-material/angular-material-tests.ts
index 3c70dd27e8..cecaf07e67 100644
--- a/angular-material/angular-material-tests.ts
+++ b/angular-material/angular-material-tests.ts
@@ -55,6 +55,18 @@ myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.
$scope['confirmDialog'] = () => {
$mdDialog.show($mdDialog.confirm().htmlContent('Confirm!'));
};
+ $scope['promptDialog'] = () => {
+ $mdDialog.show($mdDialog.prompt().textContent('Prompt!'));
+ };
+ $scope['promptDialog'] = () => {
+ $mdDialog.show($mdDialog.prompt().htmlContent('Prompt!'));
+ };
+ $scope['promptDialog'] = () => {
+ $mdDialog.show($mdDialog.prompt().cancel('Prompt "Cancel" button text'));
+ };
+ $scope['promptDialog'] = () => {
+ $mdDialog.show($mdDialog.prompt().placeholder('Prompt input placeholder text'));
+ };
$scope['hideDialog'] = $mdDialog.hide.bind($mdDialog, 'hide');
$scope['cancelDialog'] = $mdDialog.cancel.bind($mdDialog, 'cancel');
});
diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts
index 5120f76370..50389b9c72 100644
--- a/angular-material/angular-material.d.ts
+++ b/angular-material/angular-material.d.ts
@@ -4,6 +4,12 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///
+
+declare module 'angular-material' {
+ var _: string;
+ export = _;
+}
+
declare namespace angular.material {
interface IBottomSheetOptions {
@@ -59,6 +65,11 @@ declare namespace angular.material {
interface IConfirmDialog extends IPresetDialog {
cancel(cancel: string): IConfirmDialog;
}
+
+ interface IPromptDialog extends IPresetDialog {
+ cancel(cancel: string): IPromptDialog;
+ placeholder(placeholder: string): IPromptDialog;
+ }
interface IDialogOptions {
templateUrl?: string;
@@ -91,6 +102,7 @@ declare namespace angular.material {
show(dialog: IDialogOptions|IAlertDialog|IConfirmDialog): angular.IPromise;
confirm(): IConfirmDialog;
alert(): IAlertDialog;
+ prompt(): IPromptDialog;
hide(response?: any): angular.IPromise;
cancel(response?: any): void;
}
diff --git a/angular-translate/angular-translate.d.ts b/angular-translate/angular-translate.d.ts
index 045f2f5994..51946281ce 100644
--- a/angular-translate/angular-translate.d.ts
+++ b/angular-translate/angular-translate.d.ts
@@ -72,7 +72,7 @@ declare namespace angular.translate {
}
interface ITranslateProvider extends angular.IServiceProvider {
- translations(): ITranslationTable;
+ translations(key?: string): ITranslationTable;
translations(key: string, translationTable: ITranslationTable): ITranslateProvider;
cloakClassName(): string;
cloakClassName(name: string): ITranslateProvider;
diff --git a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts
index 0a7b54775e..38a1c321bd 100644
--- a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts
+++ b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts
@@ -387,6 +387,12 @@ declare namespace angular.ui.bootstrap {
* @default 'model-open'
*/
openedClass?: string;
+
+ /**
+ * CSS class(es) to be added to the top modal window.
+ */
+
+ windowTopClass?: string;
}
interface IModalStackService {
diff --git a/angular-ui-router/angular-ui-router.d.ts b/angular-ui-router/angular-ui-router.d.ts
index 0512528097..88f00c9b5d 100644
--- a/angular-ui-router/angular-ui-router.d.ts
+++ b/angular-ui-router/angular-ui-router.d.ts
@@ -35,7 +35,7 @@ declare namespace angular.ui {
/**
* String HTML content, or function that returns an HTML string
*/
- template?: string | {(): string};
+ template?: string | {(params: IStateParamsService): string};
/**
* String URL path to template file OR Function, returns URL path string
*/
@@ -229,9 +229,9 @@ declare namespace angular.ui {
*/
notify?: boolean;
/**
- * {boolean=false}, If true will force transition even if the state or params have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd use this when you want to force a reload when everything is the same, including search params.
+ * {boolean=false|string|IState}, If true will force transition even if the state or params have not changed, aka a reload of the same state. It differs from reloadOnSearch because you'd use this when you want to force a reload when everything is the same, including search params.
*/
- reload?: boolean;
+ reload?: boolean | string | IState;
}
interface IHrefOptions {
diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts
index 2f3cbc0f18..f68cd60d14 100644
--- a/angularjs/angular-animate.d.ts
+++ b/angularjs/angular-animate.d.ts
@@ -19,14 +19,14 @@ declare namespace angular.animate {
}
interface IAnimateCallbackObject {
- eventFn?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
- setClass?: (element: IAugmentedJQuery, addedClasses: string, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
- addClass?: (element: IAugmentedJQuery, addedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
- removeClass?: (element: IAugmentedJQuery, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
- enter?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
- leave?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
- move?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
- animate?: (element: IAugmentedJQuery, fromStyles: string, toStyles: string, doneFunction: Function, options: IAnimationOptions) => any;
+ eventFn?: (element: JQuery, doneFunction: Function, options: IAnimationOptions) => any;
+ setClass?: (element: JQuery, addedClasses: string, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
+ addClass?: (element: JQuery, addedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
+ removeClass?: (element: JQuery, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
+ enter?: (element: JQuery, doneFunction: Function, options: IAnimationOptions) => any;
+ leave?: (element: JQuery, doneFunction: Function, options: IAnimationOptions) => any;
+ move?: (element: JQuery, doneFunction: Function, options: IAnimationOptions) => any;
+ animate?: (element: JQuery, fromStyles: string, toStyles: string, doneFunction: Function, options: IAnimationOptions) => any;
}
interface IAnimationPromise extends IPromise {}
diff --git a/angularjs/angular-component-router.d.ts b/angularjs/angular-component-router.d.ts
index 2c56ef3a21..3b037b58b1 100644
--- a/angularjs/angular-component-router.d.ts
+++ b/angularjs/angular-component-router.d.ts
@@ -428,4 +428,55 @@ declare namespace angular {
interface OnReuse {
$routerOnReuse(next?: angular.ComponentInstruction, prev?: angular.ComponentInstruction): any;
}
+
+ /**
+ * Runtime representation a type that a Component or other object is instances of.
+ *
+ * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
+ * the `MyCustomComponent` constructor function.
+ */
+ interface Type extends Function {
+ }
+
+ /**
+ * `RouteDefinition` defines a route within a {@link RouteConfig} decorator.
+ *
+ * Supported keys:
+ * - `path` or `aux` (requires exactly one of these)
+ * - `component`, `loader`, `redirectTo` (requires exactly one of these)
+ * - `name` or `as` (optional) (requires exactly one of these)
+ * - `data` (optional)
+ *
+ * See also {@link Route}, {@link AsyncRoute}, {@link AuxRoute}, and {@link Redirect}.
+ */
+ interface RouteDefinition {
+ path?: string;
+ aux?: string;
+ component?: Type | ComponentDefinition | string;
+ loader?: Function;
+ redirectTo?: any[];
+ as?: string;
+ name?: string;
+ data?: any;
+ useAsDefault?: boolean;
+ }
+
+ /**
+ * Represents either a component type (`type` is `component`) or a loader function
+ * (`type` is `loader`).
+ *
+ * See also {@link RouteDefinition}.
+ */
+ interface ComponentDefinition {
+ type: string;
+ loader?: Function;
+ component?: Type;
+ }
+
+ // Supplement IComponentOptions from angular.d.ts with router-specific
+ // fields.
+ interface IComponentOptions {
+ $canActivate?: () => boolean;
+ $routeConfig?: RouteDefinition[];
+ }
}
diff --git a/angularjs/angular-mocks-tests.ts b/angularjs/angular-mocks-tests.ts
index 8790e68cf3..ed72401d0c 100644
--- a/angularjs/angular-mocks-tests.ts
+++ b/angularjs/angular-mocks-tests.ts
@@ -137,15 +137,19 @@ 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\/(\d+)/, 'response data', function (headers: Object): boolean { return true; }, ['id']);
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\/(\d+)/, /response data/, function (headers: Object): boolean { return true; }, ['id']);
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\/(\d+)/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }, ['id']);
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.expect('GET', /test.local\/(\d+)/, { key: 'value' }, function (headers: Object): boolean { return true; }, ['id']);
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; });
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data');
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data', { header: 'value' });
@@ -163,17 +167,21 @@ requestHandler = httpBackendService.expect('GET', (url: string) => { 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.expectDELETE(/test.local\/(\d+)/, { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectDELETE((url: string) => { return true; }, { 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.expectGET(/test.local\/(\d+)/, { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectGET((url: string) => { return true; }, { 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.expectHEAD(/test.local\/(\d+)/, { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectHEAD((url: string) => { return true; }, { header: 'value' });
requestHandler = httpBackendService.expectJSONP('http://test.local');
requestHandler = httpBackendService.expectJSONP(/test.local/);
+requestHandler = httpBackendService.expectJSONP(/test.local\/(\d+)/, ['id']);
requestHandler = httpBackendService.expectJSONP((url: string) => { return true; });
requestHandler = httpBackendService.expectPATCH('http://test.local');
@@ -188,12 +196,15 @@ requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'val
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\/(\d+)/, 'response data', { header: 'value' }, ['id']);
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\/(\d+)/, function (data: string): boolean { return true; }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' });
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.expectPATCH(/test.local\/(\d+)/, { key: 'value' }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; });
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, 'response data');
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, 'response data', { header: 'value' });
@@ -216,12 +227,15 @@ requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'valu
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\/(\d+)/, 'response data', { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/);
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPOST(/test.local\/(\d+)/, /response data/, { header: 'value' }, ['id']);
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.expectPOST(/test.local\/(\d+)/, { key: 'value' }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectPOST((url: string) => { return true; });
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, 'response data');
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, 'response data', { header: 'value' });
@@ -244,12 +258,16 @@ requestHandler = httpBackendService.expectPUT('http://test.local', { key: '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\/(\d+)/, 'response data', { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/);
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPUT(/test.local\/(\d+)/, /response data/, { header: 'value' }, ['id']);
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\/(\d+)/, function (data: string): boolean { return true; }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' });
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.expectPUT(/test.local\/(\d+)/, { key: 'value' }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.expectPUT((url: string) => { return true; });
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, 'response data');
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, 'response data', { header: 'value' });
@@ -276,16 +294,24 @@ requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'val
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\/(\d+)/, 'response data', { header: 'value' }, ['id']);
requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', /test.local\/(\d+)/, 'response data', function (headers: Object): boolean { return true; }, ['id']);
requestHandler = httpBackendService.when('GET', /test.local/, /response data/);
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.when('GET', /test.local\/(\d+)/, /response data/, { header: 'value' }, ['id']);
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', /test.local\/(\d+)/, /response data/, function (headers: Object): boolean { return true; }, ['id']);
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\/(\d+)/, function (data: string): boolean { return true; }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', /test.local\/(\d+)/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }, ['id']);
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' });
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.when('GET', /test.local\/(\d+)/, { key: 'value' }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', /test.local\/(\d+)/, { key: 'value' }, function (headers: Object): boolean { return true; }, ['id']);
requestHandler = httpBackendService.when('GET', (url: string) => { return true; });
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data');
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data', { header: 'value' });
@@ -303,17 +329,21 @@ requestHandler = httpBackendService.when('GET', (url: string) => { 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.whenDELETE(/test.local\/(\d+)/, { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenDELETE((url: string) => { return true; }, { 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.whenGET(/test.local\/(\d+)/, { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenGET((url: string) => { return true; }, { 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.whenHEAD(/test.local\/(\d+)/, { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenHEAD((url: string) => { return true; }, { header: 'value' });
requestHandler = httpBackendService.whenJSONP('http://test.local');
requestHandler = httpBackendService.whenJSONP(/test.local/);
+requestHandler = httpBackendService.whenJSONP(/test.local\/(\d+)/, ['id']);
requestHandler = httpBackendService.whenJSONP((url: string) => { return true; });
requestHandler = httpBackendService.whenPATCH('http://test.local');
@@ -328,12 +358,16 @@ requestHandler = httpBackendService.whenPATCH('http://test.local', { key: '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\/(\d+)/, 'response data', { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/);
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPATCH(/test.local\/(\d+)/, /response data/, { header: 'value' }, ['id']);
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\/(\d+)/, function (data: string): boolean { return true; }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' });
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.whenPATCH(/test.local\/(\d+)/, { key: 'value' }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; });
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, 'response data');
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, 'response data', { header: 'value' });
@@ -356,12 +390,16 @@ requestHandler = httpBackendService.whenPOST('http://test.local', { key: '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\/(\d+)/, 'response data', { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/);
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPOST(/test.local\/(\d+)/, /response data/, { header: 'value' }, ['id']);
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\/(\d+)/, function (data: string): boolean { return true; }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' });
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.whenPOST(/test.local\/(\d+)/, { key: 'value' }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenPOST((url: string) => { return true; });
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, 'response data');
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, 'response data', { header: 'value' });
@@ -384,12 +422,16 @@ requestHandler = httpBackendService.whenPUT('http://test.local', { key: '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\/(\d+)/, 'response data', { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/);
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPUT(/test.local\/(\d+)/, /response data/, { header: 'value' }, ['id']);
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\/(\d+)/, function (data: string): boolean { return true; }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' });
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.whenPUT(/test.local\/(\d+)/, { key: 'value' }, { header: 'value' }, ['id']);
requestHandler = httpBackendService.whenPUT((url: string) => { return true; });
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, 'response data');
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, 'response data', { header: 'value' });
@@ -410,6 +452,13 @@ requestHandler.passThrough().passThrough();
requestHandler.respond((method, url, data, headers) => [404, 'data', { header: 'value' }, 'responseText']);
requestHandler.respond((method, url, data, headers) => [404, 'data', { header: 'value' }, 'responseText']).respond({});
requestHandler.respond((method, url, data, headers) => { return [404, { key: 'value' }, { header: 'value' }, 'responseText']; });
+requestHandler.respond((method, url, data, headers, params) => {
+ if(params.id === 1) {
+ return [200, { key: 'value'}, { header: 'value'}, 'responseText'];
+ } else {
+ return [404, { key: 'value' }, { header: 'value' }, 'responseText'];
+ }
+});
requestHandler.respond('data');
requestHandler.respond('data').respond({});
requestHandler.respond(expectedData);
diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts
index 9031cc56d1..d1b204862f 100644
--- a/angularjs/angular-mocks.d.ts
+++ b/angularjs/angular-mocks.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module)
+// Type definitions for Angular JS 1.5 (ngMock, ngMockE2E module)
// Project: http://angularjs.org
// Definitions by: Diego Vilar , Tony Curtis
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -157,8 +157,9 @@ declare namespace angular {
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- expect(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)) :mock.IRequestHandler;
+ expect(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]) :mock.IRequestHandler;
/**
* Creates a new request expectation for DELETE requests.
@@ -166,8 +167,9 @@ declare namespace angular {
* Returns an object with respond method that controls how a matched request is handled.
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url is as expected.
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- expectDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
+ expectDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new request expectation for GET requests.
@@ -175,8 +177,9 @@ declare namespace angular {
* Returns an object with respond method that controls how a matched request is handled.
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- expectGET(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
+ expectGET(url: string | RegExp | ((url: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new request expectation for HEAD requests.
@@ -184,16 +187,19 @@ declare namespace angular {
* Returns an object with respond method that controls how a matched request is handled.
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- expectHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
+ expectHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
+
/**
* Creates a new request expectation for JSONP requests.
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false.
* Returns an object with respond method that controls how a matched request is handled.
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- */
- expectJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
+ * @param keys Array of keys to assign to regex matches in the request url.
+ */
+ expectJSONP(url: string | RegExp | ((url: string) => boolean), keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new request expectation for PATCH requests.
@@ -202,8 +208,9 @@ declare namespace angular {
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- expectPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
+ expectPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new request expectation for POST requests.
@@ -212,8 +219,9 @@ declare namespace angular {
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- expectPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
+ expectPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new request expectation for PUT requests.
@@ -222,8 +230,9 @@ declare namespace angular {
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- expectPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
+ expectPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object, keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new backend definition.
@@ -232,40 +241,46 @@ declare namespace angular {
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- when(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+ when(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new backend definition for DELETE requests.
* Returns an object with respond method that controls how a matched request is handled.
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- whenDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+ whenDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new backend definition for GET requests.
* Returns an object with respond method that controls how a matched request is handled.
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in request url described above
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- whenGET(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+ whenGET(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new backend definition for HEAD requests.
* Returns an object with respond method that controls how a matched request is handled.
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- whenHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+ whenHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new backend definition for JSONP requests.
* Returns an object with respond method that controls how a matched request is handled.
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- whenJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
+ whenJSONP(url: string | RegExp | ((url: string) => boolean), keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new backend definition for PATCH requests.
@@ -273,8 +288,9 @@ declare namespace angular {
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- whenPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+ whenPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new backend definition for POST requests.
@@ -282,8 +298,9 @@ declare namespace angular {
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- whenPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+ whenPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
/**
* Creates a new backend definition for PUT requests.
@@ -291,8 +308,9 @@ declare namespace angular {
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ * @param keys Array of keys to assign to regex matches in the request url.
*/
- whenPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+ whenPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean), keys?: Object[]): mock.IRequestHandler;
}
export module mock {
@@ -302,9 +320,9 @@ declare namespace angular {
/**
* Controls the response for a matched request using a function to construct the response.
* Returns the RequestHandler object for possible overrides.
- * @param func Function that receives the request HTTP method, url, data, and headers and returns an array containing response status (number), data, headers, and status text.
+ * @param func Function that receives the request HTTP method, url, data, headers, and an array of keys to regex matches in the request url and returns an array containing response status (number), data, headers, and status text.
*/
- respond(func: ((method: string, url: string, data: string | Object, headers: Object) => [number, string | Object, Object, string])): IRequestHandler;
+ respond(func: ((method: string, url: string, data: string | Object, headers: Object, params?: any) => [number, string | Object, Object, string])): IRequestHandler;
/**
* Controls the response for a matched request using supplied static data to construct the response.
diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts
index 0fb9351342..441a7e1d3d 100644
--- a/angularjs/angular-resource.d.ts
+++ b/angularjs/angular-resource.d.ts
@@ -95,7 +95,7 @@ declare namespace angular.resource {
(params: Object, data: Object, success?: Function, error?: Function): IResourceArray;
}
- // Baseclass for everyresource with default actions.
+ // Baseclass for every resource 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.
//
@@ -113,7 +113,7 @@ declare namespace angular.resource {
// 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 {
- new(dataOrParams? : any) : T;
+ new(dataOrParams? : any) : T & IResource;
get: IResourceMethod;
query: IResourceArrayMethod;
diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts
index 0539ae62ac..7eaf0be763 100644
--- a/angularjs/angular-tests.ts
+++ b/angularjs/angular-tests.ts
@@ -476,6 +476,8 @@ function test_angular_forEach() {
var element = angular.element("div.myApp");
var scope: ng.IScope = element.scope();
var isolateScope: ng.IScope = element.isolateScope();
+isolateScope = element.find('div.foo').isolateScope();
+isolateScope = element.children().isolateScope();
// $timeout signature tests
@@ -867,7 +869,7 @@ angular.module('docsTabsExample', [])
angular.module('componentExample', [])
.component('counter', {
- require: ['^ctrl'],
+ require: {'ctrl': '^ctrl'},
bindings: {
count: '='
},
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index 3d2b248637..1ae64c8e45 100644
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -81,7 +81,7 @@ declare namespace angular {
*
* If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite."
*/
- element: IAugmentedJQueryStatic;
+ element: JQueryStatic;
equals(value1: any, value2: any): boolean;
extend(destination: any, ...sources: any[]): any;
@@ -156,7 +156,7 @@ declare namespace angular {
noop(...args: any[]): void;
reloadWithDebugInfo(): void;
- toJson(obj: any, pretty?: boolean): string;
+ toJson(obj: any, pretty?: boolean | number): string;
uppercase(str: string): string;
version: {
full: string;
@@ -389,9 +389,9 @@ declare namespace angular {
$submitted: boolean;
$error: any;
$pending: any;
- $addControl(control: INgModelController): void;
- $removeControl(control: INgModelController): void;
- $setValidity(validationErrorKey: string, isValid: boolean, control: INgModelController): void;
+ $addControl(control: INgModelController | IFormController): void;
+ $removeControl(control: INgModelController | IFormController): void;
+ $setValidity(validationErrorKey: string, isValid: boolean, control: INgModelController | IFormController): void;
$setDirty(): void;
$setPristine(): void;
$commitViewValue(): void;
@@ -883,6 +883,24 @@ declare namespace angular {
unwrapPromises(): boolean;
unwrapPromises(value: boolean): IParseProvider;
+
+ /**
+ * Configure $parse service to add literal values that will be present as literal at expressions.
+ *
+ * @param literalName Token for the literal value. The literal name value must be a valid literal name.
+ * @param literalValue Value for this literal. All literal values must be primitives or `undefined`.
+ **/
+ addLiteral(literalName: string, literalValue: any): void;
+
+ /**
+ * Allows defining the set of characters that are allowed in Angular expressions. The function identifierStart will get called to know if a given character is a valid character to be the first character for an identifier. The function identifierContinue will get called to know if a given character is a valid character to be a follow-up identifier character. The functions identifierStart and identifierContinue will receive as arguments the single character to be identifier and the character code point. These arguments will be string and numeric. Keep in mind that the string parameter can be two characters long depending on the character representation. It is expected for the function to return true or false, whether that character is allowed or not.
+ * Since this function will be called extensivelly, keep the implementation of these functions fast, as the performance of these functions have a direct impact on the expressions parsing speed.
+ *
+ * @param identifierStart The function that will decide whether the given character is a valid identifier start character.
+ * @param identifierContinue The function that will decide whether the given character is a valid identifier continue character.
+ **/
+ setIdentifierFns(identifierStart?: (character: string, codePoint: number) => boolean,
+ identifierContinue?: (character: string, codePoint: number) => boolean): void;
}
interface ICompiledExpression {
@@ -968,7 +986,7 @@ declare namespace angular {
// DocumentService
// see http://docs.angularjs.org/api/ng.$document
///////////////////////////////////////////////////////////////////////////
- interface IDocumentService extends IAugmentedJQuery {}
+ interface IDocumentService extends JQuery {}
///////////////////////////////////////////////////////////////////////////
// ExceptionHandlerService
@@ -1231,15 +1249,15 @@ declare namespace angular {
// This corresponds to the "publicLinkFn" returned by $compile.
interface ITemplateLinkingFunction {
- (scope: IScope, cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
+ (scope: IScope, cloneAttachFn?: ICloneAttachFunction): JQuery;
}
// This corresponds to $transclude (and also the transclude function passed to link).
interface ITranscludeFunction {
// If the scope is provided, then the cloneAttachFn must be as well.
- (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery;
+ (scope: IScope, cloneAttachFn: ICloneAttachFunction): JQuery;
// If one argument is provided, then it's assumed to be the cloneAttachFn.
- (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery;
+ (cloneAttachFn?: ICloneAttachFunction): JQuery;
}
///////////////////////////////////////////////////////////////////////////
@@ -1656,50 +1674,6 @@ declare namespace angular {
// see http://angularjs.blogspot.com.br/2015/11/angularjs-15-beta2-and-14-releases.html
// and http://toddmotto.com/exploring-the-angular-1-5-component-method/
///////////////////////////////////////////////////////////////////////////
- /**
- * Runtime representation a type that a Component or other object is instances of.
- *
- * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
- * the `MyCustomComponent` constructor function.
- */
- interface Type extends Function {
- }
-
- /**
- * `RouteDefinition` defines a route within a {@link RouteConfig} decorator.
- *
- * Supported keys:
- * - `path` or `aux` (requires exactly one of these)
- * - `component`, `loader`, `redirectTo` (requires exactly one of these)
- * - `name` or `as` (optional) (requires exactly one of these)
- * - `data` (optional)
- *
- * See also {@link Route}, {@link AsyncRoute}, {@link AuxRoute}, and {@link Redirect}.
- */
- interface RouteDefinition {
- path?: string;
- aux?: string;
- component?: Type | ComponentDefinition | string;
- loader?: Function;
- redirectTo?: any[];
- as?: string;
- name?: string;
- data?: any;
- useAsDefault?: boolean;
- }
-
- /**
- * Represents either a component type (`type` is `component`) or a loader function
- * (`type` is `loader`).
- *
- * See also {@link RouteDefinition}.
- */
- interface ComponentDefinition {
- type: string;
- loader?: Function;
- component?: Type;
- }
-
/**
* Component definition object (a simplified directive definition object)
*/
@@ -1709,7 +1683,7 @@ declare namespace angular {
* controller if passed as a string. Empty function by default.
* Use the array form to define dependencies (necessary if strictDi is enabled and you require dependency injection)
*/
- controller?: string | Function | (string | Function)[];
+ controller?: string | Function | (string | Function)[] | IComponentController;
/**
* An identifier name for a reference to the controller. If present, the controller will be published to scope under
* the controllerAs name. If not present, this will default to be the same as the component name.
@@ -1742,11 +1716,52 @@ declare namespace angular {
* Whether transclusion is enabled. Enabled by default.
*/
transclude?: boolean | string | {[slot: string]: string};
- require?: string | string[] | {[controller: string]: string};
+ require?: {[controller: string]: string};
}
interface IComponentTemplateFn {
- ( $element?: IAugmentedJQuery, $attrs?: IAttributes ): string;
+ ( $element?: JQuery, $attrs?: IAttributes ): string;
+ }
+
+ /**
+ * Components have a well-defined lifecycle Each component can implement "lifecycle hooks". These are methods that
+ * will be called at certain points in the life of the component.
+ * @url https://docs.angularjs.org/guide/component
+ */
+ interface IComponentController {
+ /**
+ * Called on each controller after all the controllers on an element have been constructed and had their bindings
+ * initialized (and before the pre & post linking functions for the directives on this element). This is a good
+ * place to put initialization code for your controller.
+ */
+ $onInit?(): void;
+ /**
+ * Called whenever one-way bindings are updated. The changesObj is a hash whose keys are the names of the bound
+ * properties that have changed, and the values are an {@link IChangesObject} object of the form
+ * { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
+ * cloning the bound value to prevent accidental mutation of the outer value.
+ */
+ $onChanges?(changesObj: {[property:string]: IChangesObject}): void;
+ /**
+ * Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
+ * watches and event handlers.
+ */
+ $onDestroy?(): void;
+ /**
+ * Called after this controller's element and its children have been linked. Similar to the post-link function this
+ * hook can be used to set up DOM event handlers and do direct DOM manipulation. Note that child elements that contain
+ * templateUrl directives will not have been compiled and linked since they are waiting for their template to load
+ * asynchronously and their own compilation and linking has been suspended until that occurs. This hook can be considered
+ * analogous to the ngAfterViewInit and ngAfterContentInit hooks in Angular 2. Since the compilation process is rather
+ * different in Angular 1 there is no direct mapping and care should be taken when upgrading.
+ */
+ $postInit?(): void;
+ }
+
+ interface IChangesObject {
+ currentValue: any;
+ previousValue: any;
+ isFirstChange(): boolean;
}
///////////////////////////////////////////////////////////////////////////
@@ -1762,7 +1777,7 @@ declare namespace angular {
interface IDirectiveLinkFn {
(
scope: IScope,
- instanceElement: IAugmentedJQuery,
+ instanceElement: JQuery,
instanceAttributes: IAttributes,
controller: {},
transclude: ITranscludeFunction
@@ -1776,7 +1791,7 @@ declare namespace angular {
interface IDirectiveCompileFn {
(
- templateElement: IAugmentedJQuery,
+ templateElement: JQuery,
templateAttributes: IAttributes,
/**
* @deprecated
@@ -1818,44 +1833,14 @@ declare namespace angular {
}
/**
- * angular.element
- * when calling angular.element, angular returns a jQuery object,
- * augmented with additional methods like e.g. scope.
- * see: http://docs.angularjs.org/api/angular.element
+ * These interfaces are kept for compatibility with older versions of these type definitions.
+ * Actually, Angular doesn't create a special subclass of jQuery objects. It extends jQuery.prototype
+ * like jQuery plugins do, that's why all jQuery objects have these Angular-specific methods, not
+ * only those returned from angular.element.
+ * See: http://docs.angularjs.org/api/angular.element
*/
- interface IAugmentedJQueryStatic extends JQueryStatic {
- (selector: string, context?: any): IAugmentedJQuery;
- (element: Element): IAugmentedJQuery;
- (object: {}): IAugmentedJQuery;
- (elementArray: Element[]): IAugmentedJQuery;
- (object: JQuery): IAugmentedJQuery;
- (func: Function): IAugmentedJQuery;
- (array: any[]): IAugmentedJQuery;
- (): IAugmentedJQuery;
- }
-
- interface IAugmentedJQuery extends JQuery {
- // TODO: events, how to define?
- //$destroy
-
- find(selector: string): IAugmentedJQuery;
- find(element: any): IAugmentedJQuery;
- find(obj: JQuery): IAugmentedJQuery;
- controller(): any;
- controller(name: string): any;
- injector(): any;
- scope(): IScope;
-
- /**
- * Overload for custom scope interfaces
- */
- scope(): T;
- isolateScope(): IScope;
-
- inheritedData(key: string, value: any): JQuery;
- inheritedData(obj: { [key: string]: any; }): JQuery;
- inheritedData(key?: string): any;
- }
+ interface IAugmentedJQueryStatic extends JQueryStatic {}
+ interface IAugmentedJQuery extends JQuery {}
///////////////////////////////////////////////////////////////////////////
// AUTO module (angular.js)
@@ -1870,6 +1855,33 @@ declare namespace angular {
annotate(fn: Function, strictDi?: boolean): string[];
annotate(inlineAnnotatedFunction: any[]): string[];
get(name: string, caller?: string): T;
+ get(name: '$anchorScroll'): IAnchorScrollService
+ get(name: '$cacheFactory'): ICacheFactoryService
+ get(name: '$compile'): ICompileService
+ get(name: '$controller'): IControllerService
+ get(name: '$document'): IDocumentService
+ get(name: '$exceptionHandler'): IExceptionHandlerService
+ get(name: '$filter'): IFilterService
+ get(name: '$http'): IHttpService
+ get(name: '$httpBackend'): IHttpBackendService
+ get(name: '$httpParamSerializer'): IHttpParamSerializer
+ get(name: '$httpParamSerializerJQLike'): IHttpParamSerializer
+ get(name: '$interpolate'): IInterpolateService
+ get(name: '$interval'): IIntervalService
+ get(name: '$locale'): ILocaleService
+ get(name: '$location'): ILocationService
+ get(name: '$log'): ILogService
+ get(name: '$parse'): IParseService
+ get(name: '$q'): IQService
+ get(name: '$rootElement'): IRootElementService
+ get(name: '$rootScope'): IRootScopeService
+ get(name: '$sce'): ISCEService
+ get(name: '$sceDelegate'): ISCEDelegateService
+ get(name: '$templateCache'): ITemplateCacheService
+ get(name: '$templateRequest'): ITemplateRequestService
+ get(name: '$timeout'): ITimeoutService
+ get(name: '$window'): IWindowService
+ get(name: '$xhrFactory'): IXhrFactory
has(name: string): boolean;
instantiate(typeConstructor: Function, locals?: any): T;
invoke(inlineAnnotatedFunction: any[]): any;
@@ -1930,3 +1942,20 @@ declare namespace angular {
(obj: Object): string;
}
}
+
+interface JQuery {
+ // TODO: events, how to define?
+ //$destroy
+
+ find(element: any): JQuery;
+ find(obj: JQuery): JQuery;
+ controller(name?: string): any;
+ injector(): ng.auto.IInjectorService;
+ /** It's declared generic for custom scope interfaces */
+ scope(): T;
+ isolateScope(): T;
+
+ inheritedData(key: string, value: any): JQuery;
+ inheritedData(obj: { [key: string]: any; }): JQuery;
+ inheritedData(key?: string): any;
+}
diff --git a/angularjs/legacy/angular-mocks-1.3-tests.ts b/angularjs/legacy/angular-mocks-1.3-tests.ts
new file mode 100644
index 0000000000..3a3db64470
--- /dev/null
+++ b/angularjs/legacy/angular-mocks-1.3-tests.ts
@@ -0,0 +1,403 @@
+///
+
+///////////////////////////////////////
+// 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.expect('GET', (url: string) => { return true; });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data');
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data', { header: 'value' });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data', function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, /response data/);
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, /response data/, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, { key: 'value' });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, { 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.expectDELETE((url: string) => { return true; }, { 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.expectGET((url: string) => { return true; }, { 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.expectHEAD((url: string) => { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectJSONP('http://test.local');
+requestHandler = httpBackendService.expectJSONP(/test.local/);
+requestHandler = httpBackendService.expectJSONP((url: string) => { return true; });
+
+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.expectPATCH((url: string) => { return true; });
+requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, 'response data');
+requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, 'response data', { header: 'value' });
+requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, /response data/);
+requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, { key: 'value' });
+requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, { 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.expectPOST((url: string) => { return true; });
+requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, 'response data');
+requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, 'response data', { header: 'value' });
+requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, /response data/);
+requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, { key: 'value' });
+requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, { 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.expectPUT((url: string) => { return true; });
+requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, 'response data');
+requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, 'response data', { header: 'value' });
+requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, /response data/);
+requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, /response data/, { header: 'value' });
+requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, { key: 'value' });
+requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, { 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.when('GET', (url: string) => { return true; });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data');
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data', { header: 'value' });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data', function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, /response data/);
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, /response data/, { header: 'value' });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, /response data/, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, { key: 'value' });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, { key: 'value' }, { header: 'value' });
+requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, { 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.whenDELETE((url: string) => { return true; }, { 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.whenGET((url: string) => { return true; }, { 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.whenHEAD((url: string) => { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenJSONP('http://test.local');
+requestHandler = httpBackendService.whenJSONP(/test.local/);
+requestHandler = httpBackendService.whenJSONP((url: string) => { return true; });
+
+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.whenPATCH((url: string) => { return true; });
+requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, 'response data');
+requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, 'response data', { header: 'value' });
+requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, /response data/);
+requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, { key: 'value' });
+requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, { 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.whenPOST((url: string) => { return true; });
+requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, 'response data');
+requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, 'response data', { header: 'value' });
+requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, /response data/);
+requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, { key: 'value' });
+requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, { 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' });
+requestHandler = httpBackendService.whenPUT((url: string) => { return true; });
+requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, 'response data');
+requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, 'response data', { header: 'value' });
+requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, /response data/);
+requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, /response data/, { header: 'value' });
+requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, function (data: string): boolean { return true; });
+requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
+requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, { key: 'value' });
+requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
+
+
+///////////////////////////////////////
+// IRequestHandler
+///////////////////////////////////////
+var expectedData = { key: 'value'};
+requestHandler.passThrough();
+requestHandler.passThrough().passThrough();
+requestHandler.respond((method, url, data, headers) => [404, 'data', { header: 'value' }, 'responseText']);
+requestHandler.respond((method, url, data, headers) => [404, 'data', { header: 'value' }, 'responseText']).respond({});
+requestHandler.respond((method, url, data, headers) => { return [404, { key: 'value' }, { header: 'value' }, 'responseText']; });
+requestHandler.respond('data');
+requestHandler.respond('data').respond({});
+requestHandler.respond(expectedData);
+requestHandler.respond({ key: 'value' });
+requestHandler.respond({ key: 'value' }, { header: 'value' });
+requestHandler.respond({ key: 'value' }, { header: 'value' }, 'responseText');
+requestHandler.respond(404, 'data');
+requestHandler.respond(404, 'data').respond({});
+requestHandler.respond(404, { key: 'value' });
+requestHandler.respond(404, { key: 'value' }, { header: 'value' });
+requestHandler.respond(404, { key: 'value' }, { header: 'value' }, 'responseText');
diff --git a/angularjs/legacy/angular-mocks-1.3.d.ts b/angularjs/legacy/angular-mocks-1.3.d.ts
new file mode 100644
index 0000000000..1850ac266c
--- /dev/null
+++ b/angularjs/legacy/angular-mocks-1.3.d.ts
@@ -0,0 +1,318 @@
+// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module)
+// Project: http://angularjs.org
+// Definitions by: Diego Vilar , Tony Curtis
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module "angular-mocks/ngMock" {
+ var _: string;
+ export = _;
+}
+
+declare module "angular-mocks/ngMockE2E" {
+ var _: string;
+ export = _;
+}
+
+declare module "angular-mocks/ngAnimateMock" {
+ var _: string;
+ export = _;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// ngMock module (angular-mocks.js)
+///////////////////////////////////////////////////////////////////////////////
+declare module angular {
+
+ ///////////////////////////////////////////////////////////////////////////
+ // AngularStatic
+ // We reopen it to add the MockStatic definition
+ ///////////////////////////////////////////////////////////////////////////
+ interface IAngularStatic {
+ mock: IMockStatic;
+ }
+
+ // see https://docs.angularjs.org/api/ngMock/function/angular.mock.inject
+ interface IInjectStatic {
+ (...fns: Function[]): any;
+ (...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
+ strictDi(val?: boolean): void;
+ }
+
+ interface IMockStatic {
+ // see https://docs.angularjs.org/api/ngMock/function/angular.mock.dump
+ dump(obj: any): string;
+
+ inject: IInjectStatic
+
+ // see https://docs.angularjs.org/api/ngMock/function/angular.mock.module
+ module(...modules: any[]): any;
+
+ // see https://docs.angularjs.org/api/ngMock/type/angular.mock.TzDate
+ TzDate(offset: number, timestamp: number): Date;
+ TzDate(offset: number, timestamp: string): Date;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // ExceptionHandlerService
+ // see https://docs.angularjs.org/api/ngMock/service/$exceptionHandler
+ // see https://docs.angularjs.org/api/ngMock/provider/$exceptionHandlerProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface IExceptionHandlerProvider extends IServiceProvider {
+ mode(mode: string): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // TimeoutService
+ // see https://docs.angularjs.org/api/ngMock/service/$timeout
+ // Augments the original service
+ ///////////////////////////////////////////////////////////////////////////
+ interface ITimeoutService {
+ flush(delay?: number): void;
+ flushNext(expectedDelay?: number): void;
+ verifyNoPendingTasks(): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // IntervalService
+ // see https://docs.angularjs.org/api/ngMock/service/$interval
+ // Augments the original service
+ ///////////////////////////////////////////////////////////////////////////
+ interface IIntervalService {
+ flush(millis?: number): number;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // LogService
+ // see https://docs.angularjs.org/api/ngMock/service/$log
+ // Augments the original service
+ ///////////////////////////////////////////////////////////////////////////
+ interface ILogService {
+ assertEmpty(): void;
+ reset(): void;
+ }
+
+ interface ILogCall {
+ logs: string[];
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // HttpBackendService
+ // see https://docs.angularjs.org/api/ngMock/service/$httpBackend
+ ///////////////////////////////////////////////////////////////////////////
+ interface IHttpBackendService {
+ /**
+ * Flushes all pending requests using the trained responses.
+ * @param count Number of responses to flush (in the order they arrived). If undefined, all pending requests will be flushed.
+ */
+ flush(count?: number): void;
+
+ /**
+ * Resets all request expectations, but preserves all backend definitions.
+ */
+ resetExpectations(): void;
+
+ /**
+ * Verifies that all of the requests defined via the expect api were made. If any of the requests were not made, verifyNoOutstandingExpectation throws an exception.
+ */
+ verifyNoOutstandingExpectation(): void;
+
+ /**
+ * Verifies that there are no outstanding requests that need to be flushed.
+ */
+ verifyNoOutstandingRequest(): void;
+
+ /**
+ * Creates a new request expectation.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param method HTTP method.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ expect(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)) :mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for DELETE requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url is as expected.
+ * @param headers HTTP headers object to be compared with the HTTP headers in the request.
+ */
+ expectDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for GET requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object to be compared with the HTTP headers in the request.
+ */
+ expectGET(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for HEAD requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object to be compared with the HTTP headers in the request.
+ */
+ expectHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for JSONP requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ */
+ expectJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for PATCH requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ expectPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for POST requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ expectPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for PUT requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ expectPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param method HTTP method.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ when(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for DELETE requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for GET requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenGET(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for HEAD requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for JSONP requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for PATCH requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for POST requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for PUT requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+ }
+
+ export module mock {
+ // returned interface by the the mocked HttpBackendService expect/when methods
+ interface IRequestHandler {
+
+ /**
+ * Controls the response for a matched request using a function to construct the response.
+ * Returns the RequestHandler object for possible overrides.
+ * @param func Function that receives the request HTTP method, url, data, and headers and returns an array containing response status (number), data, headers, and status text.
+ */
+ respond(func: ((method: string, url: string, data: string | Object, headers: Object) => [number, string | Object, Object, string])): IRequestHandler;
+
+ /**
+ * Controls the response for a matched request using supplied static data to construct the response.
+ * Returns the RequestHandler object for possible overrides.
+ * @param status HTTP status code to add to the response.
+ * @param data Data to add to the response.
+ * @param headers Headers object to add to the response.
+ * @param responseText Response text to add to the response.
+ */
+ respond(status: number, data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
+
+ /**
+ * Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
+ * Returns the RequestHandler object for possible overrides.
+ * @param data Data to add to the response.
+ * @param headers Headers object to add to the response.
+ * @param responseText Response text to add to the response.
+ */
+ respond(data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
+
+ // Available when ngMockE2E is loaded
+ /**
+ * Any request matching a backend definition or expectation with passThrough handler will be passed through to the real backend (an XHR request will be made to the server.)
+ */
+ passThrough(): IRequestHandler;
+ }
+
+ }
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// functions attached to global object (window)
+///////////////////////////////////////////////////////////////////////////////
+//Use `angular.mock.module` instead of `module`, as `module` conflicts with commonjs.
+//declare var module: (...modules: any[]) => any;
+declare var inject: angular.IInjectStatic;
\ No newline at end of file
diff --git a/applicationinsights-js/applicationinsights-js-tests.ts b/applicationinsights-js/applicationinsights-js-tests.ts
new file mode 100644
index 0000000000..b90ec6c6fe
--- /dev/null
+++ b/applicationinsights-js/applicationinsights-js-tests.ts
@@ -0,0 +1,115 @@
+///
+// More samples on: https://github.com/Microsoft/ApplicationInsights-JS/blob/master/API-reference.md
+
+var config: Microsoft.ApplicationInsights.IConfig = {
+ instrumentationKey: "",
+ endpointUrl: "endpointUrl",
+ emitLineDelimitedJson: false,
+ accountId: "accountId",
+ sessionRenewalMs: 30,
+ sessionExpirationMs: 24 * 60 * 60 * 1000,
+ maxBatchSizeInBytes: 100 * 1024,
+ maxBatchInterval: 15,
+ enableDebug: false,
+ disableTelemetry: false,
+ verboseLogging: false,
+ diagnosticLogInterval: 10,
+ samplingPercentage: 100,
+ autoTrackPageVisitTime: true,
+ disableExceptionTracking: false,
+ disableAjaxTracking: false,
+ overridePageViewDuration: false,
+ maxAjaxCallsPerView: -1,
+ disableDataLossAnalysis: true,
+ disableCorrelationHeaders: true,
+ disableFlushOnBeforeUnload: false,
+ enableSessionStorageBuffer: false,
+ cookieDomain: ""
+};
+
+var appInsights: Microsoft.ApplicationInsights.IAppInsights = {
+ config: config,
+ context: null,
+ queue: null,
+
+ startTrackPage(name?: string) { return null; },
+ stopTrackPage(name?: string, url?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null; },
+ trackPageView(name?: string, url?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }, duration?: number) { return null; },
+ startTrackEvent(name: string) { return null },
+ stopTrackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null },
+ trackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null },
+ trackAjax(id: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number, method?: string) { return null },
+ trackException(exception: Error, handledAt?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }, severityLevel?: AI.SeverityLevel) { return null },
+ trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: { [name: string]: string; }) { return null },
+ trackTrace(message: string, properties?: { [name: string]: string; }) { return null },
+ flush() { return null },
+ setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string) { return null },
+ clearAuthenticatedUserContext() { return null },
+ _onerror(message: string, url: string, lineNumber: number, columnNumber: number, error: Error) { return null }
+};
+
+// trackPageView
+appInsights.trackPageView("page1");
+appInsights.trackPageView("page2", "http://example.com", null, null, 1000);
+
+// startTrackPage
+appInsights.startTrackPage("page");
+
+// stopTrackPage
+appInsights.stopTrackPage("page");
+appInsights.stopTrackPage("page", "http://example.com", null, null);
+
+// trackEvent
+appInsights.trackEvent("page1");
+appInsights.trackEvent("page1", null, null);
+
+// trackMetric
+appInsights.trackMetric("page1", 999);
+appInsights.trackMetric("page1", 999, 1, 1, 2, null);
+
+// trackException
+appInsights.trackException(new Error("sample error"));
+appInsights.trackException(new Error("sample error"), "handledAt", null, null);
+
+// trackTrace
+appInsights.trackTrace("message");
+appInsights.trackTrace("message", null);
+
+// flush
+appInsights.flush();
+
+// setAuthenticatedUserContext
+appInsights.setAuthenticatedUserContext("userId");
+appInsights.setAuthenticatedUserContext("userId", "accountId");
+
+// set config dynamically
+appInsights.config.instrumentationKey = "";
+
+
+// TelementryContext
+var context: Microsoft.ApplicationInsights.ITelemetryContext = appInsights.context;
+
+context.application.ver = "v0.0.0";
+context.application.build = "1.1.1";
+
+context.device.type = "sampleDevice";
+context.device.locale = "en-US";
+
+context.user.id = "userId";
+context.user.authenticatedId = "authId";
+
+context.session.id = "sessionId";
+context.session.isFirst = true;
+
+context.location.ip = "127.0.0.1";
+
+context.operation.id = "1";
+context.operation.syntheticSource = "testAgent";
+
+// track
+var data = new Microsoft.Telemetry.Base();
+var envelope = new Microsoft.Telemetry.Envelope();
+
+context.track(envelope);
+
+context.addTelemetryInitializer((envelope) => false);
\ No newline at end of file
diff --git a/applicationinsights-js/applicationinsights-js.d.ts b/applicationinsights-js/applicationinsights-js.d.ts
new file mode 100644
index 0000000000..5bb2a535f9
--- /dev/null
+++ b/applicationinsights-js/applicationinsights-js.d.ts
@@ -0,0 +1,408 @@
+// Type definitions for ApplicationInsights-JS v0.22.14
+// Project: https://github.com/Microsoft/ApplicationInsights-JS
+// Definitions by: Kamil Szostak
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare module AI {
+ enum SeverityLevel {
+ Verbose = 0,
+ Information = 1,
+ Warning = 2,
+ Error = 3,
+ Critical = 4,
+ }
+}
+
+declare module Microsoft.ApplicationInsights.Context {
+ interface IApplication {
+ /**
+ * The application version.
+ */
+ ver: string;
+ /**
+ * The application build version.
+ */
+ build: string;
+ }
+
+ interface IDevice {
+ /**
+ * The type for the current device.
+ */
+ type: string;
+ /**
+ * A device unique ID.
+ */
+ id: string;
+ /**
+ * The device OEM for the current device.
+ */
+ oemName: string;
+ /**
+ * The device model for the current device.
+ */
+ model: string;
+ /**
+ * The IANA interface type for the internet connected network adapter.
+ */
+ network: number;
+ /**
+ * The application screen resolution.
+ */
+ resolution: string;
+ /**
+ * The current display language of the operating system.
+ */
+ locale: string;
+ /**
+ * The IP address.
+ */
+ ip: string;
+ /**
+ * The device language.
+ */
+ language: string;
+ /**
+ * The OS name.
+ */
+ os: string;
+ /**
+ * The OS version.
+ */
+ osversion: string;
+ }
+
+ interface ILocation {
+ /**
+ * Client IP address for reverse lookup
+ */
+ ip: string;
+ }
+
+ interface IInternal {
+ /**
+ * The SDK version used to create this telemetry item.
+ */
+ sdkVersion: string;
+ /**
+ * The SDK agent version.
+ */
+ agentVersion: string;
+ }
+
+ interface ISample {
+ /**
+ * Sample rate
+ */
+ sampleRate: number;
+ }
+
+ interface ISession {
+ /**
+ * The session ID.
+ */
+ id: string;
+ /**
+ * The true if this is the first session
+ */
+ isFirst: boolean;
+ /**
+ * The date at which this guid was genereated.
+ * Per the spec the ID will be regenerated if more than acquisitionSpan milliseconds ellapse from this time.
+ */
+ acquisitionDate: number;
+ /**
+ * The date at which this session ID was last reported.
+ * This value should be updated whenever telemetry is sent using this ID.
+ * Per the spec the ID will be regenerated if more than renewalSpan milliseconds elapse from this time with no activity.
+ */
+ renewalDate: number;
+ }
+
+ interface IOperation {
+ /**
+ * Operation id
+ */
+ id: string;
+ /**
+ * Operation name
+ */
+ name: string;
+ /**
+ * Parent operation id
+ */
+ parentId: string;
+ /**
+ * Root operation id
+ */
+ rootId: string;
+ /**
+ * Synthetic source of the operation
+ */
+ syntheticSource: string;
+ }
+
+ interface IUser {
+ /**
+ * The telemetry configuration.
+ */
+ config: any;
+ /**
+ * The user ID.
+ */
+ id: string;
+ /**
+ * Authenticated user id
+ */
+ authenticatedId: string;
+ /**
+ * The account ID.
+ */
+ accountId: string;
+ /**
+ * The account acquisition date.
+ */
+ accountAcquisitionDate: string;
+ /**
+ * The user agent string.
+ */
+ agent: string;
+ /**
+ * The store region.
+ */
+ storeRegion: string;
+ }
+}
+
+declare module Microsoft.Telemetry {
+ class Base {
+ baseType: string;
+ constructor();
+ }
+
+ class Envelope {
+ ver: number;
+ name: string;
+ time: string;
+ sampleRate: number;
+ seq: string;
+ iKey: string;
+ flags: number;
+ deviceId: string;
+ os: string;
+ osVer: string;
+ appId: string;
+ appVer: string;
+ userId: string;
+ tags: any;
+ data: Base;
+ constructor();
+ }
+}
+
+declare module Microsoft.ApplicationInsights {
+ interface IConfig {
+ instrumentationKey?: string;
+ endpointUrl?: string;
+ emitLineDelimitedJson?: boolean;
+ accountId?: string;
+ sessionRenewalMs?: number;
+ sessionExpirationMs?: number;
+ maxBatchSizeInBytes?: number;
+ maxBatchInterval?: number;
+ enableDebug?: boolean;
+ disableExceptionTracking?: boolean;
+ disableTelemetry?: boolean;
+ verboseLogging?: boolean;
+ diagnosticLogInterval?: number;
+ samplingPercentage?: number;
+ autoTrackPageVisitTime?: boolean;
+ disableAjaxTracking?: boolean;
+ overridePageViewDuration?: boolean;
+ maxAjaxCallsPerView?: number;
+ disableDataLossAnalysis?: boolean;
+ disableCorrelationHeaders?: boolean;
+ disableFlushOnBeforeUnload?: boolean;
+ enableSessionStorageBuffer?: boolean;
+ cookieDomain?: string;
+ url?: string;
+ }
+
+ interface ITelemetryContext {
+ /**
+ * The object describing a component tracked by this object.
+ */
+ application: Context.IApplication;
+ /**
+ * The object describing a device tracked by this object.
+ */
+ device: Context.IDevice;
+ /**
+ * The object describing internal settings.
+ */
+ internal: Context.IInternal;
+ /**
+ * The object describing a location tracked by this object.
+ */
+ location: Context.ILocation;
+ /**
+ * The object describing a operation tracked by this object.
+ */
+ operation: Context.IOperation;
+ /**
+ * The object describing sampling settings.
+ */
+ sample: Context.ISample;
+ /**
+ * The object describing a user tracked by this object.
+ */
+ user: Context.IUser;
+ /**
+ * The object describing a session tracked by this object.
+ */
+ session: Context.ISession;
+ /**
+ * Adds telemetry initializer to the collection. Telemetry initializers will be called one by one
+ * before telemetry item is pushed for sending and in the order they were added.
+ */
+ addTelemetryInitializer(telemetryInitializer: (envelope: Microsoft.Telemetry.Envelope) => boolean): any;
+ /**
+ * Tracks telemetry object.
+ */
+ track(envelope: Microsoft.Telemetry.Envelope): any;
+ }
+
+ interface IAppInsights {
+ config: IConfig;
+ context: ITelemetryContext;
+ queue: (() => void)[];
+ /**
+ * Starts timing how long the user views a page or other item. Call this when the page opens.
+ * This method doesn't send any telemetry. Call {@link stopTrackTelemetry} to log the page when it closes.
+ * @param name A string that idenfities this item, unique within this HTML document. Defaults to the document title.
+ */
+ startTrackPage(name?: string): any;
+ /**
+ * Logs how long a page or other item was visible, after {@link startTrackPage}. Call this when the page closes.
+ * @param name The string you used as the name in startTrackPage. Defaults to the document title.
+ * @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
+ * @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
+ * @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
+ */
+ stopTrackPage(name?: string, url?: string, properties?: {
+ [name: string]: string;
+ }, measurements?: {
+ [name: string]: number;
+ }): any;
+ /**
+ * Logs that a page or other item was viewed.
+ * @param name The string you used as the name in startTrackPage. Defaults to the document title.
+ * @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
+ * @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
+ * @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
+ * @param duration number - the number of milliseconds it took to load the page. Defaults to undefined. If set to default value, page load time is calculated internally.
+ */
+ trackPageView(name?: string, url?: string, properties?: {
+ [name: string]: string;
+ }, measurements?: {
+ [name: string]: number;
+ }, duration?: number): any;
+ /**
+ * Start timing an extended event. Call {@link stopTrackEvent} to log the event when it ends.
+ * @param name A string that identifies this event uniquely within the document.
+ */
+ startTrackEvent(name: string): any;
+ /**
+ * Log an extended event that you started timing with {@link startTrackEvent}.
+ * @param name The string you used to identify this event in startTrackEvent.
+ * @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
+ * @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
+ */
+ stopTrackEvent(name: string, properties?: {
+ [name: string]: string;
+ }, measurements?: {
+ [name: string]: number;
+ }): any;
+ /**
+ * Log a user action or other occurrence.
+ * @param name A string to identify this event in the portal.
+ * @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
+ * @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
+ */
+ trackEvent(name: string, properties?: {
+ [name: string]: string;
+ }, measurements?: {
+ [name: string]: number;
+ }): any;
+ /**
+ * Log an AJAX request
+ * @param id Event id
+ * @param absoluteUrl Full url
+ * @param pathName Leave this parameter blank
+ * @param totalTime Total time it took for AJAX request to complete
+ * @param success Whether AJAX request succeeded or failed
+ * @param resultCode Result code returned from AJAX call
+ * @param method HTTP verb that was used (GET, POST)
+ */
+ trackAjax(id: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number, method?: string): any;
+ /**
+ * Log an exception you have caught.
+ * @param exception An Error from a catch clause, or the string error message.
+ * @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
+ * @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
+ * @param severityLevel AI.SeverityLevel - severity level
+ */
+ trackException(exception: Error, handledAt?: string, properties?: {
+ [name: string]: string;
+ }, measurements?: {
+ [name: string]: number;
+ }, severityLevel?: AI.SeverityLevel): any;
+ /**
+ * Log a numeric value that is not associated with a specific event. Typically used to send regular reports of performance indicators.
+ * To send a single measurement, use just the first two parameters. If you take measurements very frequently, you can reduce the
+ * telemetry bandwidth by aggregating multiple measurements and sending the resulting average at intervals.
+ * @param name A string that identifies the metric.
+ * @param average Number representing either a single measurement, or the average of several measurements.
+ * @param sampleCount The number of measurements represented by the average. Defaults to 1.
+ * @param min The smallest measurement in the sample. Defaults to the average.
+ * @param max The largest measurement in the sample. Defaults to the average.
+ */
+ trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: {
+ [name: string]: string;
+ }): any;
+ /**
+ * Log a diagnostic message.
+ * @param message A message string
+ * @param properties map[string, string] - additional data used to filter traces in the portal. Defaults to empty.
+ */
+ trackTrace(message: string, properties?: {
+ [name: string]: string;
+ }): any;
+ /**
+ * Immediately send all queued telemetry.
+ */
+ flush(): any;
+ /**
+ * Sets the autheticated user id and the account id in this session.
+ * User auth id and account id should be of type string. They should not contain commas, semi-colons, equal signs, spaces, or vertical-bars.
+ *
+ * @param authenticatedUserId {string} - The authenticated user id. A unique and persistent string that represents each authenticated user in the service.
+ * @param accountId {string} - An optional string to represent the account associated with the authenticated user.
+ */
+ setAuthenticatedUserContext(authenticatedUserId: string, accountId?: string): any;
+ /**
+ * Clears the authenticated user id and the account id from the user context.
+ */
+ clearAuthenticatedUserContext(): any;
+ downloadAndSetup?(config: Microsoft.ApplicationInsights.IConfig): void;
+ /**
+ * The custom error handler for Application Insights
+ * @param {string} message - The error message
+ * @param {string} url - The url where the error was raised
+ * @param {number} lineNumber - The line number where the error was raised
+ * @param {number} columnNumber - The column number for the line where the error was raised
+ * @param {Error} error - The Error object
+ */
+ _onerror(message: string, url: string, lineNumber: number, columnNumber: number, error: Error): any;
+ }
+}
diff --git a/argv/argv-tests.ts b/argv/argv-tests.ts
new file mode 100644
index 0000000000..6d73c53ec7
--- /dev/null
+++ b/argv/argv-tests.ts
@@ -0,0 +1,15 @@
+///
+import argv = require('argv');
+argv.version( 'v1.0' );
+argv.info( 'Special script info' );
+argv.clear()
+.option({
+ name: 'option',
+ short: 'o',
+ type: 'string',
+ description: 'Defines an option for your script',
+ example: "'script --opiton=value' or 'script -o value'"
+})
+.run([ '--option=123', '-o', '123' ]);
+argv.run();
+argv.help();
diff --git a/argv/argv.d.ts b/argv/argv.d.ts
new file mode 100644
index 0000000000..182ffde861
--- /dev/null
+++ b/argv/argv.d.ts
@@ -0,0 +1,59 @@
+// Type definitions for argv
+// Project: https://www.npmjs.com/package/argv
+// Definitions by: Hookclaw
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+declare module "argv" {
+ // argv module
+ type args = {
+ targets:string[],
+ options:{[key:string]:any}
+ };
+
+ type helpOption = {
+ name: string,
+ type: string,
+ short?: string,
+ description?: string,
+ example?: string
+ };
+
+ type module = {
+ mod: string,
+ description: string,
+ options: {[key:string]:helpOption}
+ };
+
+ type typeFunction = (value:any, ...arglist:any[]) => any;
+
+ type argv = {
+
+ // Runs the arguments parser
+ run: ( argv?:string[] ) => args,
+
+ // Adding options to definitions list
+ option: ( mod:helpOption|helpOption[] ) => argv,
+
+ // Creating module
+ mod: ( object:module|module[] ) => argv,
+
+ // Creates custom type function
+ type: ( name:string|{[key:string]:typeFunction}, callback?:typeFunction ) => any,
+
+ // Setting version number, and auto setting version option
+ version: ( v:string ) => argv,
+
+ // Description setup
+ info: ( mod:string, description?:module ) => argv,
+
+ // Cleans out current options
+ clear: () => argv,
+
+ // Prints out the help doc
+ help: ( mod?:string ) => argv
+
+ };
+
+ var argv:argv;
+
+ export = argv;
+}
diff --git a/async/async-tests.ts b/async/async-tests.ts
index 037481b6fa..e7af9120a1 100644
--- a/async/async-tests.ts
+++ b/async/async-tests.ts
@@ -378,6 +378,7 @@ async.auto({
async.retry(3, function (callback, results) { }, function (err, result) { });
async.retry({ times: 3, interval: 200 }, function (callback, results) { }, function (err, result) { });
+async.retry({ times: 3, interval: (retryCount) => { return 200 * retryCount; } }, function (callback, results) { }, function (err, result) { });
async.parallel([
diff --git a/async/async.d.ts b/async/async.d.ts
index c3d218fabc..6288a269a1 100644
--- a/async/async.d.ts
+++ b/async/async.d.ts
@@ -12,7 +12,7 @@ interface AsyncResultObjectCallback { (err: Error, results: Dictionary): v
interface AsyncFunction { (callback: (err?: Error, result?: T) => void): void; }
interface AsyncIterator { (item: T, callback: ErrorCallback): void; }
-interface AsyncForEachOfIterator { (item: T, key: number, callback: ErrorCallback): void; }
+interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; }
interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; }
interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCallback): void; }
interface AsyncBooleanIterator { (item: T, callback: (err: string, truthValue: boolean) => void): void; }
@@ -136,7 +136,7 @@ interface Async {
cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo;
auto(tasks: any, callback?: (error: Error, results: any) => void): void;
retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: (error: Error, results: any) => void): void;
- retry(opts: { times: number, interval: number }, task: (callback: AsyncResultCallback, results : any) => void, callback: (error: Error, results: any) => void): void;
+ retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: (error: Error, results: any) => void): void;
iterator(tasks: Function[]): Function;
apply(fn: Function, ...arguments: any[]): AsyncFunction;
nextTick(callback: Function): void;
diff --git a/atmosphere/atmosphere.d.ts b/atmosphere/atmosphere.d.ts
index bf26ba0db4..239986b3a1 100644
--- a/atmosphere/atmosphere.d.ts
+++ b/atmosphere/atmosphere.d.ts
@@ -102,5 +102,6 @@ declare namespace Atmosphere {
}
declare var atmosphere:Atmosphere.Atmosphere;
-
-
+declare module 'atmosphere' {
+ export = atmosphere;
+}
diff --git a/autobahn/autobahn.d.ts b/autobahn/autobahn.d.ts
index 9ca4c562cc..97837b52d0 100644
--- a/autobahn/autobahn.d.ts
+++ b/autobahn/autobahn.d.ts
@@ -181,7 +181,7 @@ declare namespace autobahn {
open(): void;
- close(reason: string, message: string): void;
+ close(reason?: string, message?: string): void;
onopen: (session: Session, details: any) => void;
onclose: (reason: string, details: any) => boolean;
diff --git a/aws-sdk/aws-sdk-tests.ts b/aws-sdk/aws-sdk-tests.ts
index 7411beb930..b771b86172 100644
--- a/aws-sdk/aws-sdk-tests.ts
+++ b/aws-sdk/aws-sdk-tests.ts
@@ -11,6 +11,32 @@ creds = new AWS.Credentials(str, str, str);
str = creds.accessKeyId;
+/*
+ * ECS
+ */
+var ecs:AWS.ECS
+
+ecs = new AWS.ECS();
+ecs = new AWS.ECS({apiVersion: '2012-11-05'});
+
+ecs.describeClusters({
+ clusters: ['STRING_VALUE', 'STRING_VALUE']
+ },
+ function(err, data) {
+ if (err) console.log(err, err.stack); // an error occurred
+ else console.log(data); // successful response
+ });
+
+ecs.describeTasks({
+ cluster: 'STRING_VALUE',
+ tasks: ['STRING_VALUE', 'STRING_VALUE']
+ },
+ function(err, data) {
+ if (err) console.log(err, err.stack); // an error occurred
+ else console.log(data); // successful response
+ });
+
+
/*
* SQS
*/
@@ -253,4 +279,107 @@ sqs.setQueueAttributes({
else console.log(data); // successful response
});
-
\ No newline at end of file
+
+var dynamoDBDocClient:AWS.DynamoDB.DocumentClient;
+dynamoDBDocClient = new AWS.DynamoDB.DocumentClient();
+dynamoDBDocClient = new AWS.DynamoDB.DocumentClient({});
+dynamoDBDocClient.createSet([1, 2, 3], { validate: true });
+dynamoDBDocClient.get(
+ {
+ TableName: 'TABLE_NAME',
+ Key: { userId: 'abc123', email: 'abc123@abc123.com' }
+ },
+ function(err, data) {
+ if (err) console.log(err, err.stack); // an error occurred
+ else console.log(data); // successful response
+ }
+);
+dynamoDBDocClient.put(
+ {
+ TableName: 'TABLE_NAME',
+ Item: {
+ userId: 'abc123',
+ email: 'abc123@abc123.com',
+ firstName: 'Matt',
+ lastName: 'Forrester the ' + new Date().getTime()
+ }
+ },
+ function(err, data) {
+ if (err) console.log(err, err.stack); // an error occurred
+ else console.log(data); // successful response
+ }
+);
+dynamoDBDocClient.delete(
+ {
+ TableName: 'TABLE_NAME',
+ Key: {
+ userId: 'abc123',
+ email: 'abc123@abc123.com'
+ }
+ },
+ function(err, data) {
+ if (err) console.log(err, err.stack); // an error occurred
+ else console.log(data); // successful response
+ }
+);
+dynamoDBDocClient.update(
+ {
+ TableName: 'TABLE_NAME',
+ Key: {
+ userId: 'abc123',
+ email: 'abc123@abc123.com'
+ },
+ AttributeUpdates: {
+ thingsWithWheels: {
+ Action: 'PUT',
+ Value: dynamoDBDocClient.createSet(
+ [
+ 'SkateBoard',
+ 'Skates',
+ 'Mountain Bike',
+ 'Evolve Electric Skateboard'
+ ],
+ { validate: true }
+ )
+ },
+ age: {
+ Action: 'PUT',
+ Value: 35
+ }
+ }
+ },
+ function(err, data) {
+ if (err) console.log(err, err.stack); // an error occurred
+ else console.log(data); // successful response
+ }
+);
+dynamoDBDocClient.scan(
+ {
+ TableName: 'TABLE_NAME',
+ KeyConditions: {
+ age: {
+ ComparisonOperator: 'EQ',
+ AttributeValueList: [35]
+ }
+ }
+ },
+ function(err, data) {
+ if (err) console.log(err, err.stack); // an error occurred
+ else console.log(data); // successful response
+ }
+);
+dynamoDBDocClient.query(
+ {
+ TableName: 'TABLE_NAME',
+ KeyConditions: {
+ userId: {
+ ComparisonOperator: 'EQ',
+ AttributeValueList: ['abc123']
+ }
+ }
+ },
+ function(err, data) {
+ if (err) console.log(err, err.stack); // an error occurred
+ else console.log(data); // successful response
+ }
+);
diff --git a/aws-sdk/aws-sdk.d.ts b/aws-sdk/aws-sdk.d.ts
index 64805da137..a13e03fe7a 100644
--- a/aws-sdk/aws-sdk.d.ts
+++ b/aws-sdk/aws-sdk.d.ts
@@ -154,11 +154,33 @@ declare module "aws-sdk" {
export class ECS {
constructor(options?: any);
-
+ /**
+ * Runs and maintains a desired number of tasks from a specified task definition. If the number of tasks running in a service drops below desiredCount, Amazon ECS spawns another instantiation of the task in the specified cluster. To update an existing service, see UpdateService.
+ */
createService(params: ecs.CreateServicesParams, callback: (err: any, data: any) => void): void;
+ /**
+ * Describes one or more of your clusters.
+ */
+ describeClusters(params: ecs.DescribeClustersParams, callback: (err: any, data: any) => void): void;
+ /**
+ * Describes the specified services running in your cluster.
+ */
describeServices(params: ecs.DescribeServicesParams, callback: (err: any, data: any) => void): void;
+ /**
+ * Describes a specified task or tasks.
+ */
+ describeTasks(params: ecs.DescribeTasksParams, callback: (err: any, data: any) => void): void;
+ /**
+ * Describes a task definition. You can specify a family and revision to find information about a specific task definition, or you can simply specify the family to find the latest ACTIVE revision in that family.
+ */
describeTaskDefinition(params: ecs.DescribeTaskDefinitionParams, callback: (err: any, data: any) => void): void;
+ /**
+ * Registers a new task definition from the supplied family and containerDefinitions. Optionally, you can add data volumes to your containers with the volumes parameter. For more information about task definition parameters and defaults, see Amazon ECS Task Definitions in the Amazon EC2 Container Service Developer Guide.
+ */
registerTaskDefinition(params: ecs.RegisterTaskDefinitionParams, callback: (err: any, data: any) => void): void;
+ /**
+ * Modifies the desired count, deployment configuration, or task definition used in a service.
+ */
updateService(params: ecs.UpdateServiceParams, callback: (err: any, data: any) => void): void;
}
@@ -166,12 +188,106 @@ declare module "aws-sdk" {
constructor(options?: any);
}
+ // ==========================================================
+
export module DynamoDB {
+
+ interface _DDBDC_Generic {
+ TableName: string;
+ ExpressionAttributeNames?: string[];
+ ReturnConsumedCapacity?: "INDEXES" | "TOTAL" | "NONE";
+ }
+
+ type _DDBDC_ComparisonOperator = "EQ" | "NE" | "IN" | "LE" | "LT" | "GE" | "GT" | "BETWEEN" | "NOT_NULL" | "NULL" | "CONTAINS" | "NOT_CONTAINS" | "BEGINS_WITH"
+ type _DDBDC_Keys = { [someKey: string]: any };
+ type _DDBDC_KeyComparison = {
+ [someKey: string]: {
+ AttributeValueList: any[];
+ ComparisonOperator: _DDBDC_ComparisonOperator;
+ }
+ };
+
+ interface _DDBDC_Reader extends _DDBDC_Generic {
+ ConsistentRead?: boolean;
+ ProjectionExpression?: string;
+ AttributesToGet?: string[];
+ }
+
+ interface _DDBDC_Writer extends _DDBDC_Generic {
+ ExpressionAttributeValues?: _DDBDC_Keys;
+ ReturnItemCollectionMetrics?: "SIZE" | "NONE";
+ ReturnValues?: "NONE" | "ALL_OLD" | "UPDATED_OLD" | "ALL_NEW" | "UPDATED_NEW";
+ ConditionExpression?: string;
+ ConditionalOperator?: "AND" | "OR";
+ Expected?: {
+ [someKey: string]: {
+ AttributeValueList: any[];
+ ComparisonOperator: _DDBDC_ComparisonOperator;
+ Exists: boolean;
+ Value: any;
+ }
+ }
+ }
+
+ interface UpdateParam extends _DDBDC_Writer {
+ Key: _DDBDC_Keys;
+ AttributeUpdates: {
+ [someKey: string]: {
+ Action: "PUT" | "ADD" | "DELETE";
+ Value: any
+ }
+ }
+ }
+
+ interface QueryParam extends _DDBDC_Reader {
+ ConditionalOperator?: "AND" | "OR";
+ ExclusiveStartKey?: _DDBDC_Keys;
+ ExpressionAttributeValues?: _DDBDC_Keys;
+ FilterExpression?: string;
+ IndexName?: string;
+ KeyConditionExpression?: string;
+ KeyConditions?: _DDBDC_KeyComparison;
+ Limit?: number;
+ QueryFilter?: _DDBDC_KeyComparison;
+ ScanIndexForward?: boolean;
+ Select?: "ALL_ATTRIBUTES" | "ALL_PROJECTED_ATTRIBUTES" | "SPECIFIC_ATTRIBUTES" | "COUNT";
+ }
+
+ interface ScanParam extends QueryParam {
+ Segment?: number;
+ ScanFilter?: _DDBDC_KeyComparison;
+ TotalSegments?: number;
+ }
+
+ interface GetParam extends _DDBDC_Reader {
+ Key: _DDBDC_Keys;
+ }
+
+ interface PutParam extends _DDBDC_Writer {
+ Item: _DDBDC_Keys;
+ }
+
+ interface DeleteParam extends _DDBDC_Writer {
+ Key: _DDBDC_Keys;
+ }
+
export class DocumentClient {
constructor(options?: any);
+ get(params: GetParam, next: (err: any, data: any) => void): void;
+ put(params: PutParam, next: (err: any, data: any) => void): void;
+ delete(params: DeleteParam, next: (err: any, data: any) => void): void;
+ query(params: QueryParam, next: (err: any, data: any) => void): void;
+ scan(params: ScanParam, next: (err: any, data: any) => void): void;
+ update(params: UpdateParam, next: (err: any, data: any) => void): void;
+ createSet(list: any[], options?: { validate?: boolean }): { values: any[], type: string };
+ batchGet(params: any, next: (err: any, data: any) => void): void;
+ batchWrite(params: any, next: (err: any, data: any) => void): void;
}
+
}
+// ===========================================================
+
export module SQS {
export interface SqsOptions {
@@ -1125,11 +1241,38 @@ declare module "aws-sdk" {
}
export interface DescribeServicesParams {
+ /**
+ * A list of services to describe.
+ */
services: string[];
- cluster: string;
+ /**
+ * The name of the cluster that hosts the service to describe. If you do not specify a cluster, the default cluster is assumed.
+ */
+ cluster?: string;
+ }
+
+ export interface DescribeClustersParams {
+ /**
+ * A space-separated list of cluster names or full cluster Amazon Resource Name (ARN) entries. If you do not specify a cluster, the default cluster is assumed.
+ */
+ clusters?: string[];
+ }
+
+ export interface DescribeTasksParams {
+ /**
+ * A space-separated list of task IDs or full Amazon Resource Name (ARN) entries.
+ */
+ tasks: string[];
+ /**
+ * The short name or full Amazon Resource Name (ARN) of the cluster that hosts the task to describe. If you do not specify a cluster, the default cluster is assumed.
+ */
+ cluster?: string;
}
export interface DescribeTaskDefinitionParams {
+ /**
+ * The `family` for the latest `ACTIVE` revision, `family` and `revision` (`family:revision`) for a specific revision in the family, or full Amazon Resource Name (ARN) of the task definition to describe.
+ */
taskDefinition: string;
}
diff --git a/backbone.radio/backbone.radio-tests.ts b/backbone.radio/backbone.radio-tests.ts
index 295c552af2..764fb65943 100644
--- a/backbone.radio/backbone.radio-tests.ts
+++ b/backbone.radio/backbone.radio-tests.ts
@@ -101,4 +101,10 @@ function TestGlobalApiAndChannels() {
Backbone.Radio.reply('auth', 'authenticate', onStart);
Backbone.Radio.request('auth', 'authenticate', 'pelle', 42);
-}
\ No newline at end of file
+}
+
+import Radio = require('backbone.radio');
+function TestImport() {
+ var channel: Backbone.Radio.Channel = Radio.channel('channel-name');
+ channel.command('show:view');
+}
diff --git a/backbone.radio/backbone.radio.d.ts b/backbone.radio/backbone.radio.d.ts
index 50895b0275..dd049ec1fe 100644
--- a/backbone.radio/backbone.radio.d.ts
+++ b/backbone.radio/backbone.radio.d.ts
@@ -90,3 +90,9 @@ declare namespace Backbone {
}
}
}
+
+declare module 'backbone.radio' {
+ import Backbone = require('backbone');
+
+ export = Backbone.Radio;
+}
diff --git a/backbone/backbone-global.d.ts b/backbone/backbone-global.d.ts
index 2d40a2a8a4..ef0a10f006 100644
--- a/backbone/backbone-global.d.ts
+++ b/backbone/backbone-global.d.ts
@@ -316,7 +316,7 @@ declare namespace Backbone {
stop(): void;
route(route: string, callback: Function): number;
checkUrl(e?: any): void;
- loadUrl(fragmentOverride: string): boolean;
+ loadUrl(fragmentOverride?: string): boolean;
navigate(fragment: string, options?: any): boolean;
static started: boolean;
options: any;
diff --git a/backbone/backbone-tests.ts b/backbone/backbone-tests.ts
index 3669a6c4e1..50632712a6 100644
--- a/backbone/backbone-tests.ts
+++ b/backbone/backbone-tests.ts
@@ -166,6 +166,9 @@ function test_collection() {
//////////
Backbone.history.start();
+Backbone.History.started;
+Backbone.history.loadUrl();
+Backbone.history.loadUrl('12345');
namespace v1Changes {
namespace events {
diff --git a/base64-js/base64-js-tests.ts b/base64-js/base64-js-tests.ts
new file mode 100644
index 0000000000..6852ddb626
--- /dev/null
+++ b/base64-js/base64-js-tests.ts
@@ -0,0 +1,6 @@
+///
+
+import * as base64js from 'base64-js';
+
+const bytes: Uint8Array = base64js.toByteArray('shemp');
+const decoded: string = base64js.fromByteArray(new Uint8Array(0));
diff --git a/base64-js/base64-js.d.ts b/base64-js/base64-js.d.ts
new file mode 100644
index 0000000000..cc7d2165c8
--- /dev/null
+++ b/base64-js/base64-js.d.ts
@@ -0,0 +1,10 @@
+// Type definitions for base64-js v1.1.2
+// Project: https://github.com/beatgammit/base64-js
+// Definitions by: Peter Safranek
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare module 'base64-js' {
+
+ export function toByteArray(encoded: string): Uint8Array;
+ export function fromByteArray(bytes: Uint8Array): string;
+}
diff --git a/bezier-js/bezier-js-tests.ts b/bezier-js/bezier-js-tests.ts
new file mode 100644
index 0000000000..54c629d11b
--- /dev/null
+++ b/bezier-js/bezier-js-tests.ts
@@ -0,0 +1,96 @@
+///
+
+function test() {
+
+ var bezierjs: typeof BezierJs;
+
+ var bezier = new bezierjs.Bezier([1,2,3,4]);
+ var cap = new bezierjs.BezierCap([]);
+ var point: BezierJs.Point = { x: 0, y: 0 };
+ var utils = bezier.getUtils();
+ var line: BezierJs.Line = { p1: { x:0, y: 0}, p2: {x:1, y: 1}};
+ var abc: BezierJs.ABC = { A: null, B: null, C: null };
+ var arc: BezierJs.Arc = { e: 0, s: 0, x: 0, y: 0, r: 1 };
+ var bbox: BezierJs.BBox = bezier.bbox();
+ var closest: BezierJs.Closest = { mdist: 1, mpos: 0 };
+ var inflection: BezierJs.Inflection = { values: null, x: [0], y: [0], z:[0] };
+ var minmax: BezierJs.MinMax = { min: 0, max: 0 };
+ var offset: BezierJs.Offset = { x: 0, y: 0, c: point, n: point };
+ var pair: BezierJs.Pair = { left: bezier, right: bezier };
+ var poly: BezierJs.PolyBezier = bezier.outline(1);
+ var projection: BezierJs.Projection = { x: 0, y: 0, t: 9, d: 4 };
+ var shape: BezierJs.Shape = { startcap: cap, endcap: cap, forward: bezier, back: bezier, bbox: bbox };
+ var split: BezierJs.Split = { left: bezier, right: bezier, span: [point] };
+
+ bezier.arcs();
+ bezier.clockwise;
+ bezier.compute(.5);
+ bezier.computedirection();
+ bezier.curveintersects([bezier], [bezier]);
+ bezier.derivative(0);
+ bezier.get(1);
+ bezier.getLUT()[0].x;
+ bezier.hull(0);
+ bezier.extrema();
+ bezier.intersects(bezier);
+ bezier.length();
+ bezier.lineIntersects(line);
+ bezier.normal(0);
+ bezier.offset(1,2);
+ bezier.on(point, 0);
+ bezier.order = 5;
+ bezier.outlineshapes(1,3);
+ bezier.overlaps(bezier);
+ bezier.point(9);
+ bezier.project(point);
+ bezier.raise();
+ bezier.reduce();
+ bezier.scale(4);
+ bezier.selfintersects();
+ bezier.simple();
+ bezier.split(0, 1).clockwise;
+ bezier.split(0.5).left;
+ bezier.toSVG();
+ bezier.update();
+
+ cap.virtual = true;
+
+ poly.addCurve(bezier);
+ poly.bbox();
+ poly.curve(7);
+ poly.curves[0]._3d;
+ poly.length();
+ poly.offset(9).points[0].y;
+ poly.points[0];
+
+ utils.abcratio(0, 1);
+ utils.align([point], line);
+ utils.angle(point, point, point);
+ utils.approximately(5, 7, .001);
+ utils.arcfn(1, function(){});
+ utils.bboxoverlap(bbox, bbox);
+ utils.between(0, 0, 1);
+ utils.closest([point], point);
+ utils.copy({});
+ utils.dist(point, point);
+ utils.droots([9]);
+ utils.expandbox(bbox, bbox);
+ utils.findbbox([bezier]);
+ utils.getccenter(point, point, point);
+ utils.getminmax(bezier, 'x', [0]);
+ utils.length(function(){});
+ utils.lerp(1, point, point);
+ utils.lli(offset, offset);
+ utils.lli4(point, point, point, point);
+ utils.lli8(0, 0, 0, 0, 0, 0, 0, 0);
+ utils.makeline(point, point);
+ utils.makeshape(bezier, bezier);
+ utils.map(0, 0, 0, 0, 0);
+ utils.pairiteration(bezier, bezier);
+ utils.pointsToString([point]);
+ utils.projectionratio(0, 0);
+ utils.roots([point], line);
+ utils.round(.999, .001);
+ utils.shapeintersections(shape, bbox, shape, bbox);
+
+}
\ No newline at end of file
diff --git a/bezier-js/bezier-js.d.ts b/bezier-js/bezier-js.d.ts
new file mode 100644
index 0000000000..8256f4ce99
--- /dev/null
+++ b/bezier-js/bezier-js.d.ts
@@ -0,0 +1,198 @@
+// Type definitions for Bezier.js
+// Project: https://github.com/Pomax/bezierjs
+// Definitions by: Dan Marshall
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+declare module BezierJs {
+ interface Point {
+ x: number;
+ y: number;
+ z?: number;
+ }
+ interface Projection extends Point {
+ t?: number;
+ d?: number;
+ }
+ interface Inflection {
+ x: number[];
+ y: number[];
+ z?: number[];
+ values: number[];
+ }
+ interface Offset extends Point {
+ c: Point;
+ n: Point;
+ }
+ interface Pair {
+ left: Bezier;
+ right: Bezier;
+ }
+ interface Split extends Pair {
+ span: Point[];
+ _t1?: number;
+ _t2?: number;
+ }
+ interface MinMax {
+ min: number;
+ mid?: number;
+ max: number;
+ size?: number;
+ }
+ interface BBox {
+ x: MinMax;
+ y: MinMax;
+ z?: MinMax;
+ }
+ interface Line {
+ p1: Point;
+ p2: Point;
+ }
+ interface Arc extends Point {
+ e: number;
+ r: number;
+ s: number;
+ }
+ interface Shape {
+ startcap: BezierCap;
+ forward: Bezier;
+ back: Bezier;
+ endcap: BezierCap;
+ bbox: BBox;
+ }
+ interface ABC {
+ A: Point;
+ B: Point;
+ C: Point;
+ }
+ interface Closest {
+ mdist: number;
+ mpos: number;
+ }
+ /**
+ * Bezier curve constructor. The constructor argument can be one of three things:
+ *
+ * 1. array/4 of {x:..., y:..., z:...}, z optional
+ * 2. numerical array/8 ordered x1,y1,x2,y2,x3,y3,x4,y4
+ * 3. numerical array/12 ordered x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4
+ *
+ */
+ class Bezier {
+ clockwise: boolean;
+ private _linear;
+ _3d: boolean;
+ _t1: number;
+ _t2: number;
+ _lut: Point[];
+ dpoints: Point[][];
+ order: number;
+ points: Point[];
+ dims: string[];
+ dimlen: number;
+ constructor(points: Point[]);
+ constructor(coords: number[]);
+ constructor(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4?: number, y4?: number);
+ constructor(p1: Point, p2: Point, p3: Point, p4?: Point);
+ static fromSVG(svgString: string): Bezier;
+ static getABC(n: number, S: Point, B: Point, E: Point, t: number): ABC;
+ static quadraticFromPoints(p1: Point, p2: Point, p3: Point, t: number): Bezier;
+ static cubicFromPoints(S: Point, B: Point, E: Point, t: number, d1: number): Bezier;
+ static getUtils(): typeof utils;
+ getUtils(): typeof utils;
+ valueOf(): string;
+ toString(): string;
+ toSVG(): string;
+ update(): void;
+ computedirection(): void;
+ length(): number;
+ getLUT(steps?: number): Point[];
+ on(point: Point, error: number): number;
+ project(point: Point): Projection;
+ get(t: number): Point;
+ point(idx: number): Point;
+ compute(t: number): Point;
+ raise(): Bezier;
+ derivative(t: number): Point;
+ inflections(): number[];
+ normal(t: number): Point;
+ private __normal2(t);
+ private __normal3(t);
+ private __normal(t);
+ hull(t: number): Point[];
+ split(t1: number): Split;
+ split(t1: number, t2: number): Bezier;
+ extrema(): Inflection;
+ bbox(): BBox;
+ overlaps(curve: Bezier): boolean;
+ offset(t: number, d?: number): Offset | Bezier[];
+ simple(): boolean;
+ reduce(): any[];
+ scale(d: Function): Bezier;
+ scale(d: number): Bezier;
+ outline(d1: number, d2?: number, d3?: number, d4?: number): PolyBezier;
+ outlineshapes(d1: number, d2: number): Shape[];
+ intersects(curve: Bezier): string[] | number[];
+ intersects(curve: Line): string[] | number[];
+ lineIntersects(line: Line): number[];
+ selfintersects(): string[];
+ curveintersects(c1: Bezier[], c2: Bezier[]): string[];
+ arcs(errorThreshold?: number): Arc[];
+ private _error(pc, np1, s, e);
+ private _iterate(errorThreshold, circles);
+ }
+ class BezierCap extends Bezier {
+ virtual: boolean;
+ }
+}
+declare module BezierJs.utils {
+ var Tvalues: number[];
+ var Cvalues: number[];
+ function arcfn(t: number, derivativeFn: Function): number;
+ function between(v: number, m: number, M: number): boolean;
+ function approximately(a: number, b: number, precision?: number): boolean;
+ function length(derivativeFn: Function): number;
+ function map(v: number, ds: number, de: number, ts: number, te: number): number;
+ function lerp(r: number, v1: Point, v2: Point): Point;
+ function pointToString(p: Point): string;
+ function pointsToString(points: Point[]): string;
+ function copy(obj: Object): any;
+ function angle(o: Point, v1: Point, v2: Point): number;
+ function round(v: number, d: number): number;
+ function dist(p1: Point, p2: Point): number;
+ function closest(LUT: Point[], point: Point): Closest;
+ function abcratio(t: number, n: number): number;
+ function projectionratio(t: number, n: number): number;
+ function lli8(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): Point;
+ function lli4(p1: Point, p2: Point, p3: Point, p4: Point): Point;
+ function lli(v1: Offset, v2: Offset): Point;
+ function makeline(p1: Point, p2: Point): Bezier;
+ function findbbox(sections: Bezier[]): BBox;
+ function shapeintersections(s1: Shape, bbox1: BBox, s2: Shape, bbox2: BBox): string[][] | number[][];
+ function makeshape(forward: Bezier, back: Bezier): Shape;
+ function getminmax(curve: Bezier, d: string, list: number[]): MinMax;
+ function align(points: Point[], line: Line): Point[];
+ function roots(points: Point[], line: Line): number[];
+ function droots(p: number[]): number[];
+ function inflections(points: Point[]): number[];
+ function bboxoverlap(b1: BBox, b2: BBox): boolean;
+ function expandbox(bbox: BBox, _bbox: BBox): void;
+ function pairiteration(c1: Bezier, c2: Bezier): string[];
+ function getccenter(p1: Point, p2: Point, p3: Point): Arc;
+}
+declare module BezierJs {
+ /**
+ * Poly Bezier
+ * @param {[type]} curves [description]
+ */
+ class PolyBezier {
+ curves: Bezier[];
+ private _3d;
+ points: Point[];
+ constructor(curves: Bezier[]);
+ valueOf(): string;
+ toString(): string;
+ addCurve(curve: Bezier): void;
+ length(): number;
+ curve(idx: number): Bezier;
+ bbox(): BBox;
+ offset(d: number): PolyBezier;
+ }
+}
diff --git a/bingmaps/Microsoft.Maps.d.ts b/bingmaps/Microsoft.Maps.d.ts
index c558c7a64b..1e7e464930 100644
--- a/bingmaps/Microsoft.Maps.d.ts
+++ b/bingmaps/Microsoft.Maps.d.ts
@@ -174,6 +174,7 @@ declare namespace Microsoft.Maps {
fixedMapPosition?: boolean;
height?: number;
inertiaIntensity?: number;
+ navigationBarMode?: number;
showBreadcrumb?: boolean;
showCopyright?: boolean;
showDashboard?: boolean;
@@ -216,6 +217,12 @@ declare namespace Microsoft.Maps {
getY(): number;
}
+ export enum NavigationBarMode {
+ default,
+ compact,
+ minified
+ }
+
export enum PixelReference {
control,
page,
@@ -301,12 +308,13 @@ declare namespace Microsoft.Maps {
getShowPointer(): boolean;
getTitle(): string;
getTitleAction(): any;
- getTitleClickHandler(): () => void;
+ getTitleClickHandler(): (mouseEvent?: MouseEvent) => void;
getVisible(): boolean;
getWidth(): number;
getZIndex(): number;
setHtmlContent(content: string): void;
setLocation(location: Location): void;
+ setMap(map: Map): void;
setOptions(options: InfoboxOptions): void;
toString(): string;
}
@@ -329,8 +337,8 @@ declare namespace Microsoft.Maps {
showPointer?: boolean;
pushpin?: Pushpin;
title?: string;
- titleAction?: { label?: string; eventHandler: () => void; };
- titleClickHandler?: () => void;
+ titleAction?: { label?: string; eventHandler: (mouseEvent?: MouseEvent) => void; };
+ titleClickHandler?: (mouseEvent?: MouseEvent) => void;
typeName?: InfoboxType;
visible?: boolean;
width?: number;
diff --git a/body-parser/body-parser.d.ts b/body-parser/body-parser.d.ts
index 16f639dfaf..f7e691a365 100644
--- a/body-parser/body-parser.d.ts
+++ b/body-parser/body-parser.d.ts
@@ -33,7 +33,7 @@ declare module "body-parser" {
/**
* passed to JSON.parse().
*/
- receiver?: (key: string, value: any) => any;
+ reviver?: (key: string, value: any) => any;
/**
* parse extended syntax with the qs module. (default: true)
*/
@@ -65,7 +65,7 @@ declare module "body-parser" {
/**
* passed to JSON.parse().
*/
- receiver?: (key: string, value: any) => any;
+ reviver?: (key: string, value: any) => any;
}): express.RequestHandler;
export function raw(options?: {
diff --git a/bookshelf/bookshelf-tests.ts b/bookshelf/bookshelf-tests.ts
index 92758e143a..5d6080b99a 100644
--- a/bookshelf/bookshelf-tests.ts
+++ b/bookshelf/bookshelf-tests.ts
@@ -1,17 +1,52 @@
///
///
+///
+///
import * as Knex from 'knex';
import * as Bookshelf from 'bookshelf';
+import * as assert from 'assert';
+import * as express from 'express';
+
+
+/**
+ * The examples/tests below follow Bookshelf documentation chapter after chapter: http://bookshelfjs.org/
+ */
+
+
+/* Installation, see http://bookshelfjs.org/#installation */
var knex = Knex({
- client: 'sqlite3',
+ client: 'mysql',
connection: {
- filename: ':memory:',
- },
+ host : '127.0.0.1',
+ user : 'your_database_user',
+ password : 'your_database_password',
+ database : 'myapp_test',
+ charset : 'utf8'
+ }
});
-// Examples
+var bookshelf = Bookshelf(knex);
+
+{
+ class User extends bookshelf.Model {
+ get tableName() { return 'users'; }
+ }
+
+ // In a file named something like bookshelf.js
+ const dbConfig: Knex.Config = {};
+ var knex = Knex(dbConfig);
+
+ // elsewhere, to use the bookshelf client:
+ var bookshelf = Bookshelf(knex);
+
+ class Post extends bookshelf.Model {
+ // ...
+ }
+}
+
+/* Examples, see http://bookshelfjs.org/#examples */
var bookshelf = Bookshelf(knex);
@@ -20,14 +55,14 @@ bookshelf.plugin(['virtuals']);
class User extends bookshelf.Model {
get tableName() { return 'users'; }
- messages() : Bookshelf.Collection {
- return this.hasMany(Posts);
+ messages(): Bookshelf.Collection {
+ return this.hasMany(Post);
}
}
-class Posts extends bookshelf.Model {
+class Post extends bookshelf.Model {
get tableName() { return 'messages'; }
- tags() : Bookshelf.Collection {
+ tags(): Bookshelf.Collection {
return this.belongsToMany(Tag);
}
}
@@ -36,67 +71,1256 @@ class Tag extends bookshelf.Model {
get tableName() { return 'tags'; }
}
-new User({}).where('id', 1).fetch({withRelated: ['posts.tags']})
+new User().where('id', 1).fetch({withRelated: ['posts.tags']})
.then(user => {
- console.log(user.related('posts').toJSON());
+ const posts = user.related('posts');
+ console.log(posts.toJSON());
}).catch(err => {
console.error(err);
});
+/* Plugins, see http://bookshelfjs.org/#plugins */
-// Associations
+/* Support, see http://bookshelfjs.org/#support */
+
+/* F.A.Q., see http://bookshelfjs.org/#faq*/
+
+/* Associations, see http://bookshelfjs.org/#associations */
+
+/* One-to-one, see http://bookshelfjs.org/#one-to-one */
class Book extends bookshelf.Model {
get tableName() { return 'books'; }
- summary() {
+ summary(): Summary {
return this.hasOne(Summary);
}
- pages() {
- return this.hasMany(Pages);
+ pages(): Bookshelf.Collection {
+ return this.hasMany(Page);
}
- authors() {
+ authors(): Bookshelf.Collection {
return this.belongsToMany(Author);
}
}
class Summary extends bookshelf.Model {
get tableName() { return 'summaries'; }
- book() : Book {
+ book(): Book {
return this.belongsTo(Book);
}
}
-class Pages extends bookshelf.Model {
+exports.up = (knex: Knex) => {
+ return knex.schema.createTable('books', table => {
+ table.increments('id').primary();
+ table.string('name');
+ }).createTable('summaries', table => {
+ table.increments('id').primary();
+ table.string('details');
+ table.integer('book_id').unique().references('books.id');
+ });
+};
+
+exports.down = (knex: Knex) => {
+ return knex.schema.dropTable('books')
+ .dropTable('summaries');
+};
+
+/* One-to-many, see http://bookshelfjs.org/#one-to-many */
+
+class Page extends bookshelf.Model {
get tableName() { return 'pages'; }
- book() {
+ book(): Book {
return this.belongsTo(Book);
}
}
+exports.up = (knex: Knex) => {
+ return knex.schema.createTable('books', table => {
+ table.increments('id').primary();
+ table.string('name');
+ }).createTable('pages', table => {
+ table.increments('id').primary();
+ table.string('content');
+ table.integer('book_id').references('books.id')
+ });
+};
+
+exports.down = (knex: Knex) => {
+ return knex.schema.dropTable('books')
+ .dropTable('pages');
+};
+
+/* Many-to-many, see http://bookshelfjs.org/#many-to-many */
+
class Author extends bookshelf.Model {
- get tableName() { return 'author'; }
+ get tableName() { return 'authors'; }
books() {
return this.belongsToMany(Book);
}
}
-class Site extends bookshelf.Model {
- get tableName() { return 'sites'; }
- photo() {
- return this.morphOne(Photo, 'imageable');
+exports.up = (knex: Knex) => {
+ return knex.schema.createTable('books', table => {
+ table.increments('id').primary();
+ table.string('name');
+ }).createTable('authors', table => {
+ table.increments('id').primary();
+ table.string('name');
+ }).createTable('authors_books', table => {
+ table.integer('author_id').references('authors.id');
+ table.integer('book_id').references('books.id');
+ });
+};
+
+exports.down = (knex: Knex) => {
+ return knex.schema.dropTable('books')
+ .dropTable('authors')
+ .dropTable('authors_books');
+};
+
+/* Polymorphic, see http://bookshelfjs.org/#polymorphic */
+
+{
+ class Site extends bookshelf.Model {
+ get tableName() { return 'sites'; }
+ photo(): Photo {
+ return this.morphOne(Photo, 'imageable');
+ }
+ }
+
+ class Post extends bookshelf.Model {
+ get tableName() { return 'posts'; }
+ photos(): Bookshelf.Collection {
+ return this.morphMany(Photo, 'imageable');
+ }
+ }
+
+ class Photo extends bookshelf.Model {
+ get tableName() { return 'photos'; }
+ imageable(): Photo {
+ return this.morphTo('imageable', Site, Post);
+ }
}
}
-class Post extends bookshelf.Model {
- get tableName() { return 'posts'; }
- photos() {
- return this.morphMany(Photo, 'imageable');
+/* Bookshelf, see http://bookshelfjs.org/#section-Bookshelf */
+
+/* Construction, see http://bookshelfjs.org/#Bookshelf-subsection-construction */
+
+/* new Bookshelf(), see http://bookshelfjs.org/#Bookshelf */
+
+/* Members, see http://bookshelfjs.org/#Bookshelf-subsection-members */
+
+/* bookshelf.knex, see http://bookshelfjs.org/#Bookshelf-instance-knex */
+
+/* Methods, see http://bookshelfjs.org/#Bookshelf-subsection-methods */
+
+/* bookshelf.transaction(), see http://bookshelfjs.org/#Bookshelf-instance-transaction */
+
+class Library extends bookshelf.Model {
+ get tableName() { return 'libraries'; }
+
+ relatedBooks(): Bookshelf.Collection {
+ return > this.related('books');
}
}
-class Photo extends bookshelf.Model {
- get tableName() { return 'photos'; }
- imageable() {
- return this.morphTo('imageable', Site, Post);
+bookshelf.transaction(t => {
+ return new Library({name: 'Old Books'})
+ .save(null, {transacting: t})
+ .tap(model => {
+ return Promise.map([
+ {title: 'Canterbury Tales'},
+ {title: 'Moby Dick'},
+ {title: 'Hamlet'}
+ ], info => {
+ // Some validation could take place here.
+ return new Book(info).save({'shelf_id': model.id}, {transacting: t});
+ });
+ });
+}).then(library => {
+ console.log(library.relatedBooks().pluck('title'));
+}).catch(err => {
+ console.error(err);
+});
+
+/* Type definitions */
+
+/* transactionCallback(), see http://bookshelfjs.org/#Bookshelf~transactionCallback */
+
+/* Model, see http://bookshelfjs.org/#section-Model */
+
+/* Construction, see http://bookshelfjs.org/#Model-subsection-construction */
+
+/* new Model(), see http://bookshelfjs.org/#Model */
+
+{
+ new Book({
+ title: "One Thousand and One Nights",
+ author: "Scheherazade"
+ });
+
+ class Book extends bookshelf.Model {
+ get tableName() { return 'documents'; }
+
+ constructor(json: Object) {
+ super(json);
+
+ this.on('saving', (model, attrs, options) => {
+ options.query.where('type', '=', 'book');
+ });
+ }
}
}
+
+/* model.initialize(), see http://bookshelfjs.org/#Model-instance-initialize */
+
+/* Static, see http://bookshelfjs.org/#Model-subsection-static */
+
+/* Model.collection(), see http://bookshelfjs.org/#Model-static-collection */
+
+class Customer extends bookshelf.Model {
+ get tableName() { return 'customers'; }
+}
+Customer.collection().fetch().then(collection => {
+ // ...
+});
+
+/* Model.count(), see http://bookshelfjs.org/#Model-static-count */
+
+/* Model.extend(), see http://bookshelfjs.org/#Model-static-extend */
+
+class Account extends bookshelf.Model {
+ get tableName() { return 'accounts'; }
+}
+{
+ var checkit = require('checkit');
+ var bcrypt = Promise.promisifyAll(require('bcrypt'));
+
+ class Customer extends bookshelf.Model {
+ get tableName() { return 'customers'; }
+
+ initialize() {
+ this.on('saving', this.validateSave);
+ }
+
+ validateSave() {
+ let rules: any;
+ return checkit(rules).run(this.attributes);
+ }
+
+ account() {
+ return this.belongsTo(Account);
+ }
+
+ static login(email: string, password: string): Promise {
+ if (!email || !password) throw new Error('Email and password are both required');
+ return new this({email: email.toLowerCase().trim()}).fetch({require: true}).tap(customer => {
+ return bcrypt.compareAsync(password, customer.get('password'))
+ .then((res: boolean) => {
+ if (!res) throw new Error('Invalid password');
+ });
+ });
+ }
+ }
+
+ const email = 'email';
+ const password = 'password';
+ Customer.login(email, password)
+ .then(customer => {
+ console.log(customer.omit('password'));
+ }).catch(Customer.NotFoundError, () => {
+ console.log({error: email + ' not found'});
+ }).catch(err => {
+ console.error(err);
+ });
+}
+
+/* Model.fetchAll(), see http://bookshelfjs.org/#Model-static-fetchAll */
+
+/* Model.forge(), see http://bookshelfjs.org/#Model-static-forge */
+
+/* Members, see http://bookshelfjs.org/#Model-subsection-members */
+
+/* model.hasTimestamps, see http://bookshelfjs.org/#Model-instance-hasTimestamps */
+
+/* model.idAttribute, see http://bookshelfjs.org/#Model-instance-idAttribute */
+
+/* model.tableName, see http://bookshelfjs.org/#Model-instance-tableName */
+
+class Television extends bookshelf.Model {
+ get tableName() { return 'televisions'; }
+}
+
+/* Methods, see http://bookshelfjs.org/#Model-subsection-methods */
+
+/* model.belongsTo(), see http://bookshelfjs.org/#Model-instance-belongsTo */
+
+{
+ class Book extends bookshelf.Model {
+ get tableName() { return 'books'; }
+ author(): Author {
+ return this.belongsTo(Author);
+ }
+ }
+
+ // select * from `books` where id = 1
+ // select * from `authors` where id = book.author_id
+ new Book().where({id: 1}).fetch({withRelated: ['author']}).then(book => {
+ console.log(JSON.stringify(book.related('author')));
+ });
+}
+
+/* model.belongsToMany(), see http://bookshelfjs.org/#Model-instance-belongsToMany */
+
+{
+ class Account extends bookshelf.Model {
+ get tableName() { return 'accounts'; }
+ }
+
+ class User extends bookshelf.Model {
+ get tableName() { return 'users'; }
+ allAccounts() {
+ return this.belongsToMany(Account);
+ }
+ adminAccounts() {
+ return this.belongsToMany(Account).query({where: {access: 'admin'}});
+ }
+ viewAccounts() {
+ return this.belongsToMany(Account).query({where: {access: 'readonly'}});
+ }
+ }
+
+ class Doctor extends bookshelf.Model {
+ patients(): Bookshelf.Collection {
+ return this.belongsToMany(Patient).through(Appointment);
+ }
+ }
+
+ class Appointment extends bookshelf.Model {
+ patient(): Patient {
+ return this.belongsTo(Patient);
+ }
+ doctor(): Doctor {
+ return this.belongsTo(Doctor);
+ }
+ }
+
+ class Patient extends bookshelf.Model {
+ doctors(): Bookshelf.Collection {
+ return this.belongsToMany(Doctor).through(Appointment);
+ }
+ }
+}
+
+/* model.clear(), see http://bookshelfjs.org/#Model-instance-clear */
+
+/* model.clone(), see http://bookshelfjs.org/#Model-instance-clone */
+
+/* model.count(), see http://bookshelfjs.org/#Model-instance-count */
+
+class Duck extends bookshelf.Model {
+}
+new Duck().where('color', 'blue').count('name')
+ .then(count => {
+ //...
+ });
+
+/* model.destroy(), see http://bookshelfjs.org/#Model-instance-destroy */
+new User({id: 1})
+ .destroy()
+ .then(model => {
+ // ...
+ });
+
+/* model.escape(), see http://bookshelfjs.org/#Model-instance-escape */
+
+/* model.fetch(), see http://bookshelfjs.org/#Model-instance-fetch */
+
+// select * from `books` where `ISBN-13` = '9780440180296'
+new Book({'ISBN-13': '9780440180296'})
+ .fetch()
+ .then(model => {
+ // outputs 'Slaughterhouse Five'
+ console.log(model.get('title'));
+ });
+{
+ class Edition extends bookshelf.Model {}
+ class Chapter extends bookshelf.Model {}
+ class Genre extends bookshelf.Model {}
+
+ class Book extends bookshelf.Model {
+ get tableName() { return 'books'; }
+ editions() {
+ return this.hasMany(Edition);
+ }
+ chapters() {
+ return this.hasMany(Chapter);
+ }
+ genre() {
+ return this.belongsTo(Genre);
+ }
+ }
+
+ new Book({'ISBN-13': '9780440180296'}).fetch({
+ withRelated: [
+ 'genre', 'editions',
+ { chapters: query => query.orderBy('chapter_number') }
+ ]
+ }).then(book => {
+ console.log(book.related('genre').toJSON());
+ console.log(book.related('editions').toJSON());
+ console.log(book.toJSON());
+ });
+}
+
+/* model.fetchAll(), see http://bookshelfjs.org/#Model-instance-fetchAll */
+
+/* model.format(), see http://bookshelfjs.org/#Model-instance-format */
+
+/* model.get(), see http://bookshelfjs.org/#Model-instance-get */
+const note = new bookshelf.Model();
+note.get("title");
+
+/* model.has(), see http://bookshelfjs.org/#Model-instance-has */
+
+/* model.hasChanged(), see http://bookshelfjs.org/#Model-instance-hasChanged */
+
+/* model.hasMany(), see http://bookshelfjs.org/#Model-instance-hasMany */
+
+{
+ class Author extends bookshelf.Model {
+ get tableName() { return 'authors'; }
+
+ books() {
+ return this.hasMany(Book);
+ }
+ }
+
+ // select * from `authors` where id = 1
+ // select * from `books` where author_id = 1
+ new Author().where({id: 1}).fetch({withRelated: ['books']}).then(author => {
+ console.log(JSON.stringify(author.related('books')));
+ });
+}
+
+/* model.hasOne(), see http://bookshelfjs.org/#Model-instance-hasOne */
+
+{
+ class Record extends bookshelf.Model {
+ get tableName() { return 'health_records'; }
+ }
+
+ class Patient extends bookshelf.Model {
+ get tableName() { return 'patients'; }
+ record(): Record {
+ return this.hasOne(Record);
+ }
+ }
+
+ // select * from `health_records` where `patient_id` = 1;
+ const record = new Patient({id: 1}).related('record');
+ record.fetch().then(model => {
+ // ...
+ });
+
+ // alternatively, if you don't need the relation loaded on the patient's relations hash:
+ new Patient({id: 1}).record().fetch().then(model => {
+ // ...
+ });
+}
+
+/* model.isNew(), see http://bookshelfjs.org/#Model-instance-isNew */
+
+var modelA = new bookshelf.Model();
+modelA.isNew(); // true
+
+var modelB = new bookshelf.Model({id: 1});
+modelB.isNew(); // false
+
+/* model.load(), see http://bookshelfjs.org/#Model-instance-load */
+class Posts extends bookshelf.Collection {}
+new Posts().fetch().then(collection => {
+ collection.at(0)
+ .load(['author', 'content', 'comments.tags'])
+ .then(model => {
+ JSON.stringify(model);
+ });
+});
+/*
+{
+ title: 'post title',
+ author: {...},
+ content: {...},
+ comments: [
+ {tags: [...]}, {tags: [...]}
+ ]
+}
+*/
+
+/* model.morphMany(), see http://bookshelfjs.org/#Model-instance-morphMany */
+
+class Photo extends bookshelf.Model {}
+{
+ class Post extends bookshelf.Model {
+ get tableName() { return 'posts'; }
+ photos() {
+ return this.morphMany(Photo, 'imageable');
+ }
+ }
+}
+{
+ class Post extends bookshelf.Model {
+ get tableName() { return 'posts'; }
+ photos() {
+ return this.morphMany(Photo, 'imageable', ["ImageableType", "ImageableId"]);
+ }
+ }
+}
+
+/* model.morphOne(), see http://bookshelfjs.org/#Model-instance-morphOne */
+
+{
+ class Site extends bookshelf.Model {
+ get tableName() { return 'sites'; }
+ photo() {
+ return this.morphOne(Photo, 'imageable');
+ }
+ }
+}
+{
+ class Site extends bookshelf.Model {
+ get tableName() { return 'sites'; }
+ photo() {
+ return this.morphOne(Photo, 'imageable', ["ImageableType", "ImageableId"]);
+ }
+ }
+}
+
+/* model.morphTo(), see http://bookshelfjs.org/#Model-instance-morphTo */
+
+class Site extends bookshelf.Model {}
+{
+ class Photo extends bookshelf.Model {
+ get tableName() { return 'photos'; }
+ imageable() {
+ return this.morphTo('imageable', Site, Post);
+ }
+ }
+}
+{
+ class Photo extends bookshelf.Model {
+ get tableName() { return 'photos'; }
+ imageable() {
+ return this.morphTo('imageable', ["ImageableType", "ImageableId"], Site, Post);
+ }
+ }
+}
+
+/* model.off(), see http://bookshelfjs.org/#Model-instance-off */
+
+const customer = new Customer();
+const ship = new bookshelf.Model();
+customer.off('fetched fetching');
+ship.off(); // This will remove all event listeners
+
+/* model.on(), see http://bookshelfjs.org/#Model-instance-on */
+
+customer.on('fetching', (model, columns) => {
+ // Do something before the data is fetched from the database
+});
+
+/* model.once(), see http://bookshelfjs.org/#Model-instance-once */
+
+/* model.parse(), see http://bookshelfjs.org/#Model-instance-parse */
+
+// Example of a "parse" to convert snake_case to camelCase, using `underscore.string`
+customer.parse = attrs => {
+ return _.reduce(<_.Dictionary> attrs, (memo, val, key) => {
+ (<_.Dictionary> memo)[_.camelCase(key)] = val;
+ return memo;
+ }, {});
+};
+
+/* model.previous(), see http://bookshelfjs.org/#Model-instance-previous */
+
+/* model.previousAttributes(), see http://bookshelfjs.org/#Model-instance-previousAttributes */
+
+/* model.query(), see http://bookshelfjs.org/#Model-instance-query */
+
+const model = new bookshelf.Model();
+model
+ .query('where', 'other_id', '=', '5')
+ .fetch()
+ .then(model => {
+ // ...
+ });
+
+model
+ .query({where: {other_id: '5'}, orWhere: {key: 'value'}})
+ .fetch()
+ .then(model => {
+ // ...
+ });
+
+model.query(qb => {
+ qb.where('other_person', 'LIKE', '%Demo').orWhere('other_id', '>', 10);
+}).fetch()
+ .then(model => {
+ // ...
+ });
+
+let qb = model.query();
+qb.where({id: 1}).select().then(resp => {
+ // ...
+});
+
+/* model.refresh(), see http://bookshelfjs.org/#Model-instance-refresh */
+
+/* model.related(), see http://bookshelfjs.org/#Model-instance-related */
+class Trip extends bookshelf.Model {}
+class Trips extends bookshelf.Collection {}
+new Photo({id: 1}).fetch({
+ withRelated: ['account']
+}).then(photo => {
+ if (photo) {
+ var account = photo.related('account');
+ if (account.id) {
+ return ( account.related('trips')).fetch();
+ }
+ }
+});
+
+/* model.resetQuery(), see http://bookshelfjs.org/#Model-instance-resetQuery */
+
+/* model.save(), see http://bookshelfjs.org/#Model-instance-save */
+
+new Post({name: 'New Article'}).save().then(model => {
+ // ...
+});
+// update authors set "bio" = 'Short user bio' where "id" = 1
+new Author({id: 1, first_name: 'User'})
+ .save({bio: 'Short user bio'}, {patch: true})
+ .then(model => {
+ // ...
+ });
+
+// Save with no arguments
+bookshelf.Model.forge({id: 5, firstName: "John", lastName: "Smith"}).save().then(() => {
+ //...
+});
+
+// Or add attributes during save
+bookshelf.Model.forge({id: 5}).save({firstName: "John", lastName: "Smith"}).then(() => {
+ //...
+});
+
+// Or, if you prefer, for a single attribute
+bookshelf.Model.forge({id: 5}).save('name', 'John Smith').then(() => {
+ //...
+});
+
+/* model.serialize(), see http://bookshelfjs.org/#Model-instance-serialize */
+
+var artist = new bookshelf.Model({
+ firstName: "Wassily",
+ lastName: "Kandinsky"
+});
+
+artist.set({birthday: "December 16, 1866"});
+
+console.log(JSON.stringify(artist));
+// {firstName: "Wassily", lastName: "Kandinsky", birthday: "December 16, 1866"}
+
+/* model.set(), see http://bookshelfjs.org/#Model-instance-set */
+
+customer.set({first_name: "Joe", last_name: "Customer"});
+customer.set("telephone", "555-555-1212");
+
+/* model.through(), see http://bookshelfjs.org/#Model-instance-through */
+
+{
+ class Book extends bookshelf.Model {
+ get tableName() { return 'books'; }
+
+ // Find all paragraphs associated with this book, by
+ // passing through the "Chapter" model.
+ paragraphs(): Paragraphs {
+ return this.hasMany(Paragraph).through(Chapter);
+ }
+
+ chapters(): Chapters {
+ return this.hasMany(Chapter);
+ }
+ }
+
+ class Chapter extends bookshelf.Model {
+ get tableName() { return 'chapters'; }
+
+ paragraphs(): Bookshelf.Collection {
+ return this.hasMany(Paragraph);
+ }
+ }
+
+ class Chapters extends bookshelf.Collection {
+ }
+
+ class Paragraph extends bookshelf.Model {
+ get tableName() { return 'paragraphs'; }
+
+ chapter(): Chapter {
+ return this.belongsTo(Chapter);
+ }
+
+ // A reverse relation, where we can get the book from the chapter.
+ book(): Book {
+ return this.belongsTo(Book).through(Chapter);
+ }
+ }
+
+ class Paragraphs extends bookshelf.Collection {
+ }
+}
+
+/* model.timestamp(), see http://bookshelfjs.org/#Model-instance-timestamp */
+
+/* model.toJSON(), see http://bookshelfjs.org/#Model-instance-toJSON */
+
+// TODO No example provided on Bookshelf website
+
+{
+ interface UserJson {
+ name: string;
+ }
+
+ class User extends bookshelf.Model {
+ get tableName() { return 'users'; }
+
+ toJSON(): UserJson {
+ return super.toJSON();
+ }
+
+ fetchAll(): Promise {
+ return super.fetchAll();
+ }
+ }
+
+ class Users extends bookshelf.Collection {
+ toJSON(): UserJson[] {
+ return super.toJSON();
+ }
+ }
+
+ new User({id: 1}).fetch().then(user => {
+ const userJson = user.toJSON();
+ console.log('User name:', userJson.name);
+ });
+
+ new User({name: 'John'}).fetchAll().then(users => {
+ const usersJson = users.toJSON();
+ console.log('First user name:', usersJson[0].name);
+ });
+}
+
+/* model.trigger(), see http://bookshelfjs.org/#Model-instance-trigger */
+
+ship.trigger('fetched');
+
+/* model.triggerThen(), see http://bookshelfjs.org/#Model-instance-triggerThen */
+
+/* model.unset(), see http://bookshelfjs.org/#Model-instance-unset */
+
+/* model.where(), see http://bookshelfjs.org/#Model-instance-where */
+
+model.where('favorite_color', '<>', 'green').fetch().then(() => {
+ //...
+});
+// or
+model.where('favorite_color', 'red').fetch().then(() => {
+ //...
+});
+// or
+model.where({favorite_color: 'red', shoe_size: 12}).fetch().then(() => {
+ //...
+});
+
+/* Lodash methods, see http://bookshelfjs.org/#Model-subsection-lodash-methods */
+
+/* invert(), see http://lodash.com/docs/#invert */
+
+/* keys(), see http://lodash.com/docs/#keys */
+
+/* omit(), see http://lodash.com/docs/#omit */
+
+/* pairs(), see http://lodash.com/docs/#pairs */
+
+/* pick(), see http://lodash.com/docs/#pick */
+
+/* values(), see http://lodash.com/docs/#values */
+
+/* Events, see http://bookshelfjs.org/#Model-subsection-events */
+
+/* model.on("created"), see http://bookshelfjs.org/#Model-event-created */
+
+/* model.on("creating"), see http://bookshelfjs.org/#Model-event-creating */
+
+/* model.on("destroyed"), see http://bookshelfjs.org/#Model-event-destroyed */
+
+/* model.on("destroying"), see http://bookshelfjs.org/#Model-event-destroying */
+
+/* model.on("fetched"), see http://bookshelfjs.org/#Model-event-fetched */
+
+/* model.on("fetching"), see http://bookshelfjs.org/#Model-event-fetching */
+
+/* model.on("saved"), see http://bookshelfjs.org/#Model-event-saved */
+
+/* model.on("saving"), see http://bookshelfjs.org/#Model-event-saving */
+
+/* model.on("updated"), see http://bookshelfjs.org/#Model-event-updated */
+
+/* model.on("updating"), see http://bookshelfjs.org/#Model-event-updating */
+
+/* new Model.NoRowsDeletedError(), see http://bookshelfjs.org/#Model-static-NoRowsDeletedError */
+
+// TODO No example provided on Bookshelf website
+
+new User({id: 1}).destroy({require: true})
+.then(user => {
+ console.log(user.toJSON());
+})
+.catch(User.NoRowsDeletedError, () => {
+ console.log('User not found');
+})
+.catch(error => {
+ console.log('Internal error:', error);
+});
+
+/* new Model.NoRowsUpdatedError(), see http://bookshelfjs.org/#Model-static-NoRowsUpdatedError */
+
+// TODO No example provided on Bookshelf website
+
+new User({id: 1}).save({}, {patch: true, require: true})
+.then(user => {
+ console.log(user.toJSON());
+})
+.catch(User.NoRowsUpdatedError, () => {
+ console.log('User not updated');
+})
+.catch(error => {
+ console.log('Internal error:', error);
+});
+
+/* new Model.NotFoundError(), see http://bookshelfjs.org/#Model-static-NotFoundError */
+
+// TODO No example provided on Bookshelf website
+
+new User({id: 1}).fetch({require: true})
+.then(user => {
+ console.log(user.toJSON());
+})
+.catch(User.NotFoundError, () => {
+ console.log('User not found');
+})
+.catch(error => {
+ console.log('Internal error:', error);
+});
+
+/* Collection, see http://bookshelfjs.org/#section-Collection */
+
+/* Construction, see http://bookshelfjs.org/#Collection-subsection-construction */
+
+/* new Collection(), see http://bookshelfjs.org/#Collection */
+
+class Tab extends bookshelf.Model {
+}
+const tab1 = new Tab();
+const tab2 = new Tab();
+const tab3 = new Tab();
+class TabSet extends bookshelf.Collection {
+}
+let tabs = new TabSet([tab1, tab2, tab3]);
+
+/* collection.initialize(), see http://bookshelfjs.org/#Collection-instance-initialize */
+
+/* Static, see http://bookshelfjs.org/#Collection-subsection-static */
+
+/* Collection.extend(), see http://bookshelfjs.org/#Collection-static-extend */
+
+/* Collection.forge(), see http://bookshelfjs.org/#Collection-static-forge */
+
+class Accounts extends bookshelf.Collection {
+ model: Account
+}
+
+var accounts = Accounts.forge([
+ {name: 'Person1'},
+ {name: 'Person2'}
+]);
+
+Promise.all(accounts.invoke('save')).then(() => {
+ // collection models should now be saved...
+});
+
+/* Methods, see http://bookshelfjs.org/#Collection-subsection-methods */
+
+/* collection.add(), see http://bookshelfjs.org/#Collection-instance-add */
+
+const ships = new bookshelf.Collection;
+
+ships.add([
+ {name: "Flying Dutchman"},
+ {name: "Black Pearl"}
+]);
+
+/* collection.at(), see http://bookshelfjs.org/#Collection-instance-at */
+
+/* collection.attach(), see http://bookshelfjs.org/#Collection-instance-attach */
+
+{
+ class Admin extends bookshelf.Model {
+ }
+ class Site extends bookshelf.Model {
+ admins() {
+ return this.hasMany(Admin);
+ }
+ }
+ var admin1 = new Admin({username: 'user1', password: 'test'});
+ var admin2 = new Admin({username: 'user2', password: 'test'});
+
+ Promise.all([admin1.save(), admin2.save()])
+ .then(() => {
+ return Promise.all([
+ new Site({id: 1}).admins().attach([admin1, admin2]),
+ new Site({id: 2}).admins().attach(admin2)
+ ]);
+ });
+}
+
+/* collection.clone(), see http://bookshelfjs.org/#Collection-instance-clone */
+
+/* collection.count(), see http://bookshelfjs.org/#Collection-instance-count */
+
+class Shareholder extends bookshelf.Model {}
+class Company extends bookshelf.Model {
+ shareholders() {
+ return this.hasMany(Shareholder);
+ }
+}
+
+// select count(*) from shareholders where company_id = 1 and share > 0.1;
+Company.forge({id:1})
+ .shareholders()
+ .query('where', 'share', '>', '0.1')
+ .count()
+ .then(count => {
+ assert(count === 3);
+ });
+
+/* collection.create(), see http://bookshelfjs.org/#Collection-instance-create */
+
+class Student extends bookshelf.Model {}
+
+function get(req: express.Request, res: express.Response) {
+ // FIXME Support proposed ES Rest/Spread properties https://github.com/Microsoft/TypeScript/issues/2103
+ //const { courses, ...attributes } = req.body;
+ const { courses, attributes } = req.body;
+
+ Student.forge(attributes).save().tap(student =>
+ Promise.map(courses, course => (> student.related('courses')).create(course))
+ ).then(student =>
+ res.status(200).send(student)
+ ).catch(error =>
+ res.status(500).send(error.message)
+ );
+}
+
+/* collection.detach(), see http://bookshelfjs.org/#Collection-instance-detach */
+
+/* collection.fetch(), see http://bookshelfjs.org/#Collection-instance-fetch */
+
+/* collection.fetchOne(), see http://bookshelfjs.org/#Collection-instance-fetchOne */
+
+{
+ class Site extends bookshelf.Model {
+ authors() {
+ return this.hasMany(Author);
+ }
+ }
+
+ // select * from authors where site_id = 1 and id = 2 limit 1;
+ new Site({id: 1})
+ .authors()
+ .query({where: {id: 2}})
+ .fetchOne()
+ .then(model => {
+ // ...
+ });
+}
+
+/* collection.findWhere(), see http://bookshelfjs.org/#Collection-instance-findWhere */
+
+/* collection.get(), see http://bookshelfjs.org/#Collection-instance-get */
+
+const library = new bookshelf.Collection();
+const book = library.get(110);
+
+/* collection.invokeThen(), see http://bookshelfjs.org/#Collection-instance-invokeThen */
+
+const options = {};
+const collection = new bookshelf.Collection();
+collection.invokeThen('save', null, options).then(() => {
+ // ... all models in the collection have been saved
+});
+
+collection.invokeThen('destroy', options).then(() => {
+ // ... all models in the collection have been destroyed
+});
+
+/* collection.load(), see http://bookshelfjs.org/#Collection-instance-load */
+
+/* collection.off(), see http://bookshelfjs.org/#Collection-instance-off */
+
+ships.off('fetched') // Remove the 'fetched' event listener
+
+/* collection.on(), see http://bookshelfjs.org/#Collection-instance-on */
+
+ships.on('fetched', (collection, response) => {
+ // Do something after the data has been fetched from the database
+})
+
+/* collection.once(), see http://bookshelfjs.org/#Collection-instance-once */
+
+/* collection.parse(), see http://bookshelfjs.org/#Collection-instance-parse */
+
+/* collection.pluck(), see http://bookshelfjs.org/#Collection-instance-pluck */
+
+/* collection.pop(), see http://bookshelfjs.org/#Collection-instance-pop */
+
+/* collection.push(), see http://bookshelfjs.org/#Collection-instance-push */
+
+/* collection.query(), see http://bookshelfjs.org/#Collection-instance-query */
+
+{
+ let qb = collection.query();
+ qb.where({id: 1}).select().then(resp => {
+ // ...
+ });
+
+ collection.query(qb => {
+ qb.where('id', '>', 5).andWhere('first_name', '=', 'Test');
+ }).fetch()
+ .then(collection => {
+ // ...
+ });
+
+ collection
+ .query('where', 'other_id', '=', '5')
+ .fetch()
+ .then(collection => {
+ // ...
+ });
+}
+
+/* collection.reduceThen(), see http://bookshelfjs.org/#Collection-instance-reduceThen */
+
+/* collection.remove(), see http://bookshelfjs.org/#Collection-instance-remove */
+
+/* collection.reset(), see http://bookshelfjs.org/#Collection-instance-reset */
+
+/* collection.resetQuery(), see http://bookshelfjs.org/#Collection-instance-resetQuery */
+
+/* collection.serialize(), see http://bookshelfjs.org/#Collection-instance-serialize */
+
+/* collection.set(), see http://bookshelfjs.org/#Collection-instance-set */
+
+class BandMember extends bookshelf.Model {}
+const eddie = new BandMember();
+const alex = new BandMember();
+const stone = new BandMember();
+const roth = new BandMember();
+const hagar = new BandMember();
+var vanHalen = new bookshelf.Collection([eddie, alex, stone, roth]);
+vanHalen.set([eddie, alex, stone, hagar]);
+
+/* collection.shift(), see http://bookshelfjs.org/#Collection-instance-shift */
+
+/* collection.slice(), see http://bookshelfjs.org/#Collection-instance-slice */
+
+/* collection.through(), see http://bookshelfjs.org/#Collection-instance-through */
+
+/* collection.toJSON(), see http://bookshelfjs.org/#Collection-instance-toJSON */
+
+/* collection.trigger(), see http://bookshelfjs.org/#Collection-instance-trigger */
+
+ships.trigger('fetched');
+
+/* collection.triggerThen(), see http://bookshelfjs.org/#Collection-instance-triggerThen */
+
+/* collection.unshift(), see http://bookshelfjs.org/#Collection-instance-unshift */
+
+/* collection.updatePivot(), see http://bookshelfjs.org/#Collection-instance-updatePivot */
+
+/* collection.where(), see http://bookshelfjs.org/#Collection-instance-where */
+
+/* collection.withPivot(), see http://bookshelfjs.org/#Collection-instance-withPivot */
+
+{
+ class Comment extends bookshelf.Model {}
+ class Tag extends bookshelf.Model {
+ comments() {
+ return this.belongsToMany(Comment).withPivot(['created_at', 'order']);
+ }
+ }
+}
+
+/* Lodash methods, see http://bookshelfjs.org/#Collection-subsection-lodash-methods */
+
+/* all(), see http://lodash.com/docs/#all */
+
+/* any(), see http://lodash.com/docs/#any */
+
+/* chain(), see http://lodash.com/docs/#chain */
+
+/* collect(), see http://lodash.com/docs/#collect */
+
+/* contains(), see http://lodash.com/docs/#contains */
+
+/* countBy(), see http://lodash.com/docs/#countBy */
+
+/* detect(), see http://lodash.com/docs/#detect */
+
+/* difference(), see http://lodash.com/docs/#difference */
+
+/* drop(), see http://lodash.com/docs/#drop */
+
+/* each(), see http://lodash.com/docs/#each */
+
+/* every(), see http://lodash.com/docs/#every */
+
+/* filter(), see http://lodash.com/docs/#filter */
+
+/* find(), see http://lodash.com/docs/#find */
+
+/* first(), see http://lodash.com/docs/#first */
+
+/* foldl(), see http://lodash.com/docs/#foldl */
+
+/* foldr(), see http://lodash.com/docs/#foldr */
+
+/* forEach(), see http://lodash.com/docs/#forEach */
+
+/* groupBy(), see http://lodash.com/docs/#groupBy */
+
+/* head(), see http://lodash.com/docs/#head */
+
+/* include(), see http://lodash.com/docs/#include */
+
+/* indexOf(), see http://lodash.com/docs/#indexOf */
+
+/* initial(), see http://lodash.com/docs/#initial */
+
+/* inject(), see http://lodash.com/docs/#inject */
+
+/* invoke(), see http://lodash.com/docs/#invoke */
+
+/* isEmpty(), see http://lodash.com/docs/#isEmpty */
+
+/* last(), see http://lodash.com/docs/#last */
+
+/* lastIndexOf(), see http://lodash.com/docs/#lastIndexOf */
+
+/* map(), see http://lodash.com/docs/#map */
+
+// TODO No example provided on Bookshelf website
+
+{
+ class Author extends bookshelf.Model {
+ get tableName() { return 'author'; }
+ books() {
+ return this.belongsToMany(Book);
+ }
+ relatedBooks() {
+ return > this.related('books');
+ }
+ }
+ new Author({id: 1}).fetch({require: true, withRelated: ['books']})
+ .then(author => {
+ const books = author.relatedBooks();
+ const booksJson = books.map(book => book.toJSON());
+ });
+
+ class AuthorOutput {
+ constructor(bookJson: Object) {}
+ }
+
+ new Author({id: 1}).fetch({require: true, withRelated: ['books']})
+ .then(author => {
+ const books = author.relatedBooks();
+ const booksOutput = books.map(book => new AuthorOutput(book.toJSON()));
+ });
+}
+
+/* max(), see http://lodash.com/docs/#max */
+
+/* min(), see http://lodash.com/docs/#min */
+
+/* reduce(), see http://lodash.com/docs/#reduce */
+
+/* reduceRight(), see http://lodash.com/docs/#reduceRight */
+
+/* reject(), see http://lodash.com/docs/#reject */
+
+/* rest(), see http://lodash.com/docs/#rest */
+
+/* select(), see http://lodash.com/docs/#select */
+
+/* shuffle(), see http://lodash.com/docs/#shuffle */
+
+/* size(), see http://lodash.com/docs/#size */
+
+/* some(), see http://lodash.com/docs/#some */
+
+/* sortBy(), see http://lodash.com/docs/#sortBy */
+
+/* tail(), see http://lodash.com/docs/#tail */
+
+/* take(), see http://lodash.com/docs/#take */
+
+/* toArray(), see http://lodash.com/docs/#toArray */
+
+/* without(), see http://lodash.com/docs/#without */
+
+/* Events, see http://bookshelfjs.org/#Collection-subsection-events */
+
+/* collection.on("fetched"), see http://bookshelfjs.org/#Collection-event-fetched */
+
+/* new Collection.EmptyError(), see http://bookshelfjs.org/#Collection-static-EmptyError */
+
+// TODO No example provided on Bookshelf website
+
+class Users extends bookshelf.Collection {
+}
+new User({name: 'John'}).fetchAll({require: true})
+.then(users => {
+ console.log(users.toJSON());
+})
+.catch(Users.EmptyError, () => {
+ console.log('No user found');
+})
+.catch(error => {
+ console.log('Internal error:', error);
+});
+
+/* Events, see http://bookshelfjs.org/#section-Events */
+
+/* new Events(), see http://bookshelfjs.org/#Events */
+
+/* events.off(), see http://bookshelfjs.org/#Events-instance-off */
+
+/* events.on(), see http://bookshelfjs.org/#Events-instance-on */
+
+/* events.once(), see http://bookshelfjs.org/#Events-instance-once */
+
+/* events.trigger(), see http://bookshelfjs.org/#Events-instance-trigger */
+
+/* events.triggerThen(), see http://bookshelfjs.org/#Events-instance-triggerThen */
diff --git a/bookshelf/bookshelf.d.ts b/bookshelf/bookshelf.d.ts
index cf70220840..0ca3a1ebcd 100644
--- a/bookshelf/bookshelf.d.ts
+++ b/bookshelf/bookshelf.d.ts
@@ -6,23 +6,25 @@
///
///
///
+///
declare module 'bookshelf' {
- import knex = require('knex');
- import Promise = require('bluebird');
- import Lodash = require('lodash');
+ import * as Knex from 'knex';
+ import * as Promise from 'bluebird';
+ import * as Lodash from 'lodash';
+ import * as createError from 'create-error';
interface Bookshelf extends Bookshelf.Events {
VERSION : string;
- knex : knex;
+ knex : Knex;
Model : typeof Bookshelf.Model;
Collection : typeof Bookshelf.Collection;
plugin(name: string | string[] | Function, options?: any) : Bookshelf;
- transaction(callback : (transaction : knex.Transaction) => T) : Promise;
+ transaction(callback : (transaction : Knex.Transaction) => T) : T;
}
- function Bookshelf(knex : knex) : Bookshelf;
+ function Bookshelf(knex : Knex) : Bookshelf;
namespace Bookshelf {
abstract class Events {
@@ -44,6 +46,13 @@ declare module 'bookshelf' {
/** If overriding, must use a getter instead of a plain property. */
idAttribute : string;
+ // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/model.js#L178
+ // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/model.js#L213
+ id : any;
+
+ // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/model.js#L28
+ attributes : any;
+
constructor(attributes? : any, options? : ModelOptions);
clear() : T;
@@ -54,7 +63,7 @@ declare module 'bookshelf' {
has(attribute : string) : boolean;
hasChanged(attribute? : string) : boolean;
isNew() : boolean;
- parse(response : any) : any;
+ parse(response : Object) : Object;
previousAttributes() : any;
previous(attribute : string) : any;
related>(relation : string) : R | Collection;
@@ -88,7 +97,7 @@ declare module 'bookshelf' {
belongsTo>(target : {new(...args : any[]) : R}, foreignKey? : string) : R;
belongsToMany>(target : {new(...args : any[]) : R}, table? : string, foreignKey? : string, otherKey? : string) : Collection;
count(column? : string, options? : SyncOptions) : Promise;
- destroy(options? : SyncOptions) : Promise;
+ destroy(options? : DestroyOptions) : Promise;
fetch(options? : FetchOptions) : Promise;
fetchAll(options? : FetchAllOptions) : Promise>;
hasMany>(target : {new(...args : any[]) : R}, foreignKey? : string) : Collection;
@@ -98,20 +107,35 @@ declare module 'bookshelf' {
morphOne>(target : {new(...args : any[]) : R}, name? : string, columnNames? : string[], morphValue? : string) : R;
morphTo(name : string, columnNames? : string[], ...target : typeof Model[]) : T;
morphTo(name : string, ...target : typeof Model[]) : T;
+
+ // Declaration order matters otherwise TypeScript gets confused between query() and query(...query: string[])
+ query() : Knex.QueryBuilder;
+ query(callback : (qb : Knex.QueryBuilder) => void) : T;
query(...query : string[]) : T;
query(query : {[key : string] : any}) : T;
- query(callback : (qb : knex.QueryBuilder) => void) : T;
- query() : knex.QueryBuilder;
+
refresh(options? : FetchOptions) : Promise;
resetQuery() : T;
- save(key? : string, val? : string, options? : SaveOptions) : Promise;
+ save(key? : string, val? : any, options? : SaveOptions) : Promise;
save(attrs? : {[key : string] : any}, options? : SaveOptions) : Promise;
- through>(interim : typeof Model, throughForeignKey? : string, otherKey? : string) : R | Collection;
+ through>(interim : typeof Model, throughForeignKey? : string, otherKey? : string) : R;
where(properties : {[key : string] : any}) : T;
where(key : string, operatorOrValue : string|number|boolean, valueIfOperator? : string|number|boolean) : T;
+
+ // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/errors.js
+ // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/model.js#L1280
+ static NotFoundError: createError.Error;
+ static NoRowsUpdatedError: createError.Error;
+ static NoRowsDeletedError: createError.Error;
}
abstract class CollectionBase> extends Events {
+ // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/collection.js#L573
+ length : number;
+
+ // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/collection.js#L21
+ constructor(models? : T[], options? : CollectionOptions);
+
add(models : T[]|{[key : string] : any}[], options? : CollectionAddOptions) : Collection;
at(index : number) : T;
clone() : Collection;
@@ -127,11 +151,11 @@ declare module 'bookshelf' {
remove(model : T, options? : EventOptions) : T;
remove(model : T[], options? : EventOptions) : T[];
reset(model : any[], options? : CollectionAddOptions) : T[];
- serialize(options? : SerializeOptions) : any;
+ serialize(options? : SerializeOptions) : any[];
set(models : T[]|{[key : string] : any}[], options? : CollectionSetOptions) : Collection;
shift(options? : EventOptions) : void;
slice(begin? : number, end? : number) : void;
- toJSON(options? : SerializeOptions) : any;
+ toJSON(options? : SerializeOptions) : any[];
unshift(model : any, options? : CollectionAddOptions) : void;
where(match : {[key : string] : any}, firstOnly : boolean) : T|Collection;
@@ -177,8 +201,13 @@ declare module 'bookshelf' {
keys() : string[];
last() : T;
lastIndexOf(value : any, fromIndex? : number) : number;
- map(predicate? : Lodash.ListIterator|Lodash.DictionaryIterator|string, thisArg? : any) : T[];
- map(predicate? : R) : T[];
+
+ // See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1ec3d51/lodash/lodash-3.10.d.ts#L7119
+ // See https://github.com/Microsoft/TypeScript/blob/v1.8.10/lib/lib.core.es7.d.ts#L1122
+ map(predicate? : Lodash.ListIterator|string, thisArg? : any) : U[];
+ map(predicate? : Lodash.DictionaryIterator|string, thisArg? : any) : U[];
+ map(predicate? : string) : U[];
+
max(predicate? : Lodash.ListIterator|string, thisArg? : any) : T;
max(predicate? : R) : T;
min(predicate? : Lodash.ListIterator|string, thisArg? : any) : T;
@@ -208,20 +237,27 @@ declare module 'bookshelf' {
/** @deprecated should use `new` objects instead. */
static forge(attributes? : any, options? : ModelOptions) : T;
- attach(ids : any[], options? : SyncOptions) : Promise>;
+ attach(ids : any|any[], options? : SyncOptions) : Promise>;
count(column? : string, options? : SyncOptions) : Promise;
create(model : {[key : string] : any}, options? : CollectionCreateOptions) : Promise;
detach(ids : any[], options? : SyncOptions) : Promise;
+ detach(options? : SyncOptions) : Promise;
fetchOne(options? : CollectionFetchOneOptions) : Promise;
load(relations : string|string[], options? : SyncOptions) : Promise>;
+
+ // Declaration order matters otherwise TypeScript gets confused between query() and query(...query: string[])
+ query() : Knex.QueryBuilder;
+ query(callback : (qb : Knex.QueryBuilder) => void) : Collection;
query(...query : string[]) : Collection;
query(query : {[key : string] : any}) : Collection;
- query(callback : (qb : knex.QueryBuilder) => void) : Collection;
- query() : knex.QueryBuilder;
+
resetQuery() : Collection;
- through>(interim : typeof Model, throughForeignKey? : string, otherKey? : string) : R | Collection;
+ through>(interim : typeof Model, throughForeignKey? : string, otherKey? : string) : Collection;
updatePivot(attributes : any, options? : PivotOptions) : Promise;
withPivot(columns : string[]) : Collection;
+
+ // See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/collection.js#L389
+ static EmptyError: createError.Error;
}
interface ModelOptions {
@@ -231,13 +267,17 @@ declare module 'bookshelf' {
}
interface LoadOptions extends SyncOptions {
- withRelated: string|any|any[];
+ withRelated : (string|WithRelatedQuery)[];
}
interface FetchOptions extends SyncOptions {
require? : boolean;
columns? : string|string[];
- withRelated? : string|any|any[];
+ withRelated? : (string|WithRelatedQuery)[];
+ }
+
+ interface WithRelatedQuery {
+ [index : string] : (query : Knex.QueryBuilder) => Knex.QueryBuilder;
}
interface FetchAllOptions extends SyncOptions {
@@ -251,6 +291,10 @@ declare module 'bookshelf' {
require? : boolean;
}
+ interface DestroyOptions extends SyncOptions {
+ require? : boolean;
+ }
+
interface SerializeOptions {
shallow? : boolean;
omitPivot? : boolean;
@@ -265,7 +309,7 @@ declare module 'bookshelf' {
}
interface SyncOptions {
- transacting? : knex.Transaction;
+ transacting? : Knex.Transaction;
debug? : boolean;
}
diff --git a/bootstrap.datepicker/bootstrap.datepicker.d.ts b/bootstrap.datepicker/bootstrap.datepicker.d.ts
index 686cc6b423..f60a0ffed6 100644
--- a/bootstrap.datepicker/bootstrap.datepicker.d.ts
+++ b/bootstrap.datepicker/bootstrap.datepicker.d.ts
@@ -15,7 +15,7 @@
* http://bootstrap-datepicker.readthedocs.org/en/release/options.html
*/
interface DatepickerOptions {
- format?: string;
+ format?: string | DatepickerCustomFormatOptions;
weekStart?: number;
startDate?: any;
endDate?: any;
@@ -38,6 +38,11 @@ interface DatepickerOptions {
assumeNearbyYear?: any;
}
+interface DatepickerCustomFormatOptions {
+ toDisplay?(date: string, format: any, language: any): string;
+ toValue?(date: string, format: any, language: any): Date;
+}
+
interface DatepickerEventObject extends JQueryEventObject {
date: Date;
format(format?: string): string;
diff --git a/bootstrap/bootstrap-tests.ts b/bootstrap/bootstrap-tests.ts
index c497e0abcd..f7cfdeab43 100644
--- a/bootstrap/bootstrap-tests.ts
+++ b/bootstrap/bootstrap-tests.ts
@@ -44,3 +44,8 @@ $('.typeahead').typeahead({
});
$('#navbar').affix();
+
+$('.item').emulateTransitionEnd(2000);
+
+$.support.transition = false;
+console.log(($.support.transition as TransitionEventNames).end === "transitionend");
diff --git a/bootstrap/bootstrap.d.ts b/bootstrap/bootstrap.d.ts
index b0e8fbf858..ae84454332 100644
--- a/bootstrap/bootstrap.d.ts
+++ b/bootstrap/bootstrap.d.ts
@@ -53,7 +53,7 @@ interface PopoverOptions {
}
interface CollapseOptions {
- parent?: any;
+ parent?: any;
toggle?: boolean;
}
@@ -79,6 +79,10 @@ interface AffixOptions {
target?: any;
}
+interface TransitionEventNames {
+ end: string;
+}
+
interface JQuery {
modal(options?: ModalOptions): JQuery;
modal(options?: ModalOptionsBackdropString): JQuery;
@@ -114,6 +118,12 @@ interface JQuery {
typeahead(options?: TypeaheadOptions): JQuery;
affix(options?: AffixOptions): JQuery;
+
+ emulateTransitionEnd(duration: number): JQuery;
+}
+
+interface JQuerySupport {
+ transition: boolean | TransitionEventNames;
}
declare module "bootstrap" {
diff --git a/browser-pack/browser-pack-tests.ts b/browser-pack/browser-pack-tests.ts
new file mode 100644
index 0000000000..4cf20249e8
--- /dev/null
+++ b/browser-pack/browser-pack-tests.ts
@@ -0,0 +1,33 @@
+///
+
+import browserPack = require("browser-pack");
+
+module BrowserPackTest {
+
+ export function packIt(opts?: BrowserPack.Options) {
+ var packOpts: BrowserPack.Options = {
+ basedir: opts.basedir || "./",
+ externalRequireName: opts.externalRequireName || "require",
+ hasExports: opts.hasExports || false,
+ prelude: opts.prelude || undefined,
+ preludePath: opts.preludePath || undefined,
+ raw: opts.raw || false,
+ sourceMapPrefix: opts.sourceMapPrefix || '//#',
+ standalone: opts.standalone || undefined,
+ standaloneModule: opts.standaloneModule || undefined,
+ };
+
+ var res = browserPack(); // 'opts' are optional
+ var res2 = browserPack(packOpts);
+
+ // ensure return value is a stream
+ var res3 = res.pipe(res2);
+
+ res.on("error", function (err: any) {
+ console.error("browser-pack error: ", err);
+ });
+ }
+
+}
+
+export = BrowserPackTest;
\ No newline at end of file
diff --git a/browser-pack/browser-pack.d.ts b/browser-pack/browser-pack.d.ts
new file mode 100644
index 0000000000..52b96ce134
--- /dev/null
+++ b/browser-pack/browser-pack.d.ts
@@ -0,0 +1,61 @@
+// Type definitions for browser-pack v6.0.1
+// Project: https://github.com/substack/browser-pack
+// Definitions by: TeamworkGuy2
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+///
+
+/** pack node-style source files from a json stream into a browser bundle
+ */
+declare module BrowserPack {
+
+ export interface Options {
+ /** Whether the bundle should include require= (or the opts.externalRequireName) so that
+ * require() is available outside the bundle
+ */
+ hasExports?: boolean;
+
+ /** A string to use in place of 'require' if opts.hasExports is specified, default is 'require'
+ */
+ externalRequireName?: string;
+
+ /** Specify a custom prelude, but know what you're doing first. See the prelude.js file in
+ * this repo for the default prelude. If you specify a custom prelude, you must also specify
+ * a valid opts.preludePath to the prelude source file for sourcemaps to work
+ */
+ prelude?: string;
+
+ /** prelude.js path if a custom opts.prelude is specified
+ */
+ preludePath?: string;
+
+ /** Used if opts.preludePath is undefined, this is used to resolve the prelude.js file location, default: 'process.cwd()'
+ */
+ basedir?: string;
+
+ /** if given, the writable end of the stream will expect objects to be written to
+ * it instead of expecting a stream of json text it will need to parse, default false
+ */
+ raw?: boolean;
+
+ /** External string name to use for UMD, if not provided, UMD declaration is not wrapped around output
+ */
+ standalone?: string;
+
+ /** Sets the internal module name to export for standalone
+ */
+ standaloneModule?: string;
+
+ /** If given and source maps are computed, the opts.sourceMapPrefix string will be used instead of default: '//#'
+ */
+ sourceMapPrefix?: string;
+ }
+
+}
+
+declare module "browser-pack" {
+ /** pack node-style source files from a json stream into a browser bundle
+ */
+ function browserPack(opts?: BrowserPack.Options): NodeJS.ReadWriteStream;
+ export = browserPack;
+}
\ No newline at end of file
diff --git a/browser-resolve/browser-resolve-tests.ts b/browser-resolve/browser-resolve-tests.ts
new file mode 100644
index 0000000000..071b17a1d2
--- /dev/null
+++ b/browser-resolve/browser-resolve-tests.ts
@@ -0,0 +1,39 @@
+///
+
+import * as browserResolve from 'browser-resolve';
+
+function basic_test_async(callback: (err?: Error, resolved?: string) => void) {
+ browserResolve('typescript', function(error, resolved) {
+ if (error) {
+ return callback(error);
+ }
+ callback(null, resolved);
+ });
+}
+
+function basic_test_sync() {
+ var resolved = browserResolve.sync('typescript');
+}
+
+function options_test_async() {
+ browserResolve('typescript', {
+ browser: 'jsnext:main',
+ filename: './browser-resolve/browser-resolve.js',
+ modules: {
+ fs: './fs-shim.js'
+ }
+ }, function(error, resolved) {
+ if (error) {
+ console.error(error);
+ return;
+ }
+ console.log(resolved);
+ });
+}
+
+function options_test_sync() {
+ var resolved = browserResolve.sync('typescript', {
+ filename: './browser-resolve/browser-resolve.js',
+ modules: {}
+ });
+}
diff --git a/browser-resolve/browser-resolve.d.ts b/browser-resolve/browser-resolve.d.ts
new file mode 100644
index 0000000000..8c1456c8f0
--- /dev/null
+++ b/browser-resolve/browser-resolve.d.ts
@@ -0,0 +1,61 @@
+// Type definitions for browser-resolve
+// Project: https://github.com/defunctzombie/node-browser-resolve
+// Definitions by: Mario Nebl
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+///
+
+declare module 'browser-resolve' {
+ import * as resolve from 'resolve';
+
+ /**
+ * Callback invoked when resolving asynchronously
+ *
+ * @param error
+ * @param resolved Absolute path to resolved identifier
+ */
+ type resolveCallback = (err?: Error, resolved?: string) => void;
+
+ /**
+ * Resolve a module path and call cb(err, path [, pkg])
+ *
+ * @param id Identifier to resolve
+ * @param callback
+ */
+ function browserResolve(id: string, cb: resolveCallback): void;
+
+ /**
+ * Resolve a module path and call cb(err, path [, pkg])
+ *
+ * @param id Identifier to resolve
+ * @param options Options to use for resolving, optional.
+ * @param callback
+ */
+ function browserResolve(id: string, opts: browserResolve.AsyncOpts, cb: resolveCallback): void;
+
+ /**
+ * Returns a module path
+ *
+ * @param id Identifier to resolve
+ * @param options Options to use for resolving, optional.
+ */
+ function browserResolveSync(id: string, opts?: browserResolve.SyncOpts): string;
+
+ namespace browserResolve {
+ interface Opts {
+ // the 'browser' property to use from package.json (defaults to 'browser')
+ browser?: string;
+ // the calling filename where the require() call originated (in the source)
+ filename?: string;
+ // modules object with id to path mappings to consult before doing manual resolution (use to provide core modules)
+ modules?: any;
+ }
+
+ export interface AsyncOpts extends resolve.AsyncOpts, Opts {}
+ export interface SyncOpts extends resolve.SyncOpts, Opts {}
+
+ export var sync: typeof browserResolveSync;
+ }
+
+ export = browserResolve
+}
diff --git a/browser-sync/browser-sync-tests.ts b/browser-sync/browser-sync-tests.ts
index 822c941d9f..72bcb6465e 100644
--- a/browser-sync/browser-sync-tests.ts
+++ b/browser-sync/browser-sync-tests.ts
@@ -1,5 +1,5 @@
///
-import browserSync = require("browser-sync");
+import * as browserSync from "browser-sync";
(() => {
//make sure that the interfaces are correctly exposed
diff --git a/browser-sync/browser-sync.d.ts b/browser-sync/browser-sync.d.ts
index 3bc083d1f1..00d234f958 100644
--- a/browser-sync/browser-sync.d.ts
+++ b/browser-sync/browser-sync.d.ts
@@ -8,10 +8,10 @@
///
declare module "browser-sync" {
- import chokidar = require("chokidar");
- import fs = require("fs");
- import http = require("http");
- import mm = require("micromatch");
+ import * as chokidar from "chokidar";
+ import * as fs from "fs";
+ import * as http from "http";
+ import * as mm from "micromatch";
namespace browserSync {
interface Options {
@@ -23,14 +23,14 @@ declare module "browser-sync" {
* weinre.port - Default: 8080
* Note: requires at least version 2.0.0
*/
- ui?: UIOptions;
+ ui?: UIOptions | boolean;
/**
* Browsersync can watch your files as you work. Changes you make will either be injected into the page (CSS
* & images) or will cause all browsers to do a full-page refresh. See anymatch for more information on glob
* patterns.
* Default: false
*/
- files?: string | string[];
+ files?: string | (string | FileCallback)[];
/**
* File watching options that get passed along to Chokidar. Check their docs for available options
* Default: undefined
@@ -245,7 +245,7 @@ declare module "browser-sync" {
* Note: requires at least version 1.6.2
*/
socket?: SocketOptions;
- middleware?: MiddlewareHandler | MiddlewareHandler[];
+ middleware?: MiddlewareHandler | PerRouteMiddleware | (MiddlewareHandler | PerRouteMiddleware)[];
}
interface Hash {
@@ -261,6 +261,12 @@ declare module "browser-sync" {
};
}
+ interface FileCallback {
+ match?: string | string[];
+ fn: (event: string, file: string) => any;
+ options?: chokidar.WatchOptions;
+ }
+
interface ServerOptions {
/** set base directory */
baseDir?: string | string[];
@@ -274,7 +280,7 @@ declare module "browser-sync" {
*/
routes?: Hash;
/** configure custom middleware */
- middleware?: MiddlewareHandler[];
+ middleware?: (MiddlewareHandler | PerRouteMiddleware)[];
}
interface ProxyOptions {
@@ -289,6 +295,11 @@ declare module "browser-sync" {
(req: http.ServerRequest, res: http.ServerResponse, next: Function): any;
}
+ interface PerRouteMiddleware {
+ route: string;
+ handle: MiddlewareHandler;
+ }
+
interface GhostOptions {
clicks?: boolean;
scroll?: boolean;
diff --git a/bytebuffer/bytebuffer.d.ts b/bytebuffer/bytebuffer.d.ts
index e5d267787f..e87fb710d8 100644
--- a/bytebuffer/bytebuffer.d.ts
+++ b/bytebuffer/bytebuffer.d.ts
@@ -91,7 +91,7 @@ declare class ByteBuffer
/**
* Data view to manipulate the backing buffer. Becomes null if the backing buffer has a capacity of 0.
*/
- view: DataView;
+ view: DataView;
/**
* Allocates a new ByteBuffer backed by a buffer of the specified capacity.
@@ -424,7 +424,7 @@ declare class ByteBuffer
/**
* Resizes this ByteBuffer to be backed by a buffer of at least the given capacity. Will do nothing if already that large or larger.
- */
+ */
resize( capacity: number ): ByteBuffer;
/**
@@ -611,6 +611,5 @@ declare class ByteBuffer
}
declare module 'bytebuffer' {
- namespace ByteBuffer {}
export = ByteBuffer;
}
diff --git a/c3/c3-tests.ts b/c3/c3-tests.ts
index 5413db82d7..cc15e11abe 100644
--- a/c3/c3-tests.ts
+++ b/c3/c3-tests.ts
@@ -290,7 +290,7 @@ function legend_examples() {
},
item: {
onclick: function(id) { /* code */ },
- onmoouseover: function(id) { /* code */ },
+ onmouseover: function(id) { /* code */ },
onmouseout: function(id) { /* code */ },
}
}
diff --git a/c3/c3.d.ts b/c3/c3.d.ts
index 32dee37dce..f5159090d2 100644
--- a/c3/c3.d.ts
+++ b/c3/c3.d.ts
@@ -650,7 +650,7 @@ declare namespace c3 {
/**
* Set mouseover event handler to the legend item.
*/
- onmoouseover?: (id: any) => void;
+ onmouseover?: (id: any) => void;
/**
* Set mouseout event handler to the legend item.
*/
diff --git a/cachefactory/cachefactory-tests.ts b/cachefactory/cachefactory-tests.ts
new file mode 100644
index 0000000000..0c859e749d
--- /dev/null
+++ b/cachefactory/cachefactory-tests.ts
@@ -0,0 +1,34 @@
+///
+
+CacheFactory.get('test');
+
+CacheFactory.createCache('test', {
+ deleteOnExpire: 'aggressive',
+ recycleFreq: 60000
+});
+
+let testCache = CacheFactory.get('test');
+
+testCache.put('testOne', {title: 'testOne', id: 1});
+
+let item = testCache.get('testOne');
+
+
+let profileCache = CacheFactory('profileCache', {
+ maxAge: 60 * 60 * 1000,
+ deleteOnExpire: 'aggressive'
+});
+
+let localStoragePolyfill = {
+ getItem: (key: string) => { return ""; },
+ setItem: (key: string, value: string) => { },
+ removeItem: (key: string) => { }
+};
+
+let myAwesomeCache = CacheFactory('myAwesomeCache', {
+ maxAge: 15 * 60 * 1000,
+ cacheFlushInterval: 60 * 60 * 1000,
+ deleteOnExpire: 'aggressive',
+ storageMode: 'localStorage',
+ storageImpl: localStoragePolyfill
+});
\ No newline at end of file
diff --git a/cachefactory/cachefactory.d.ts b/cachefactory/cachefactory.d.ts
new file mode 100644
index 0000000000..ac416e6837
--- /dev/null
+++ b/cachefactory/cachefactory.d.ts
@@ -0,0 +1,443 @@
+// Type definitions for CacheFactory 1.4.0
+// Project: https://github.com/jmdobry/CacheFactory
+// Definitions by: Vaggelis Mparmpas , Daniel Massa
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare module CacheFactory {
+ export interface IStoreImplementation {
+ getItem(key: string): string;
+
+ setItem(key: string, value: string): void;
+
+ removeItem(key: string): void;
+ }
+
+ export interface CacheGetOptions {
+ /*
+ * A callback function to be executed whenever an expired item is removed from a cache when the cache is in passive
+ * or aggressive mode. Will be passed the key and value of the expired item.
+ *
+ * Will be passed a third done argument if the cache is in passive mode. This allows you to synchronously access the
+ * key and value of the expired item when you make the cache#get(key[, options]) call that is the reason the expired
+ * item is being removed in the first place. Default: null.
+ */
+ onExpire?(key: string, value: any): any;
+ }
+
+ export interface CachePutOptions {
+ /*
+ * The number of milliseconds until a newly inserted item expires. Default: Number.MAX_VALUE.
+ */
+ maxAge?: number;
+
+ /*
+ * If inserting a promise into a cache, also insert the rejection value if the promise rejects. Default: false.
+ */
+ storeOnReject?: boolean;
+
+ /*
+ * If inserting a promise into a cache, also insert the resolved value if the promise resolves. Default: false.
+ */
+ storeOnResolve?: boolean;
+
+ created?: Date;
+ access?: Date;
+ expires?: Date;
+ }
+
+ export interface CacheTouchOptions extends CachePutOptions { }
+
+ export interface CacheOptions {
+ /*
+ * If set, remove all items from a cache on an interval after the given number of milliseconds. Default: null.
+ */
+ cacheFlushInterval?: number;
+
+ /*
+ * Maximum number of items a cache can hold. Adding more items than the capacity will cause the cache to operate
+ * like an LRU cache, removing the least recently used items to stay under capacity. Default: Number.MAX_VALUE.
+ */
+
+ capacity?: number;
+
+ /*
+ * Determines the behavior of a cache when an item expires. Default: none.
+ *
+ * Possible values:
+ *
+ * none - cache will do nothing when an item expires.
+ * passive - cache will do nothing when an item expires. Expired items will remain in the cache until requested,
+ * at which point they are removed, and undefined is returned.
+ * aggressive - cache will remove expired items as soon as they are discovered.
+ */
+ deleteOnExpire?: string;
+
+ /*
+ * Determines whether a cache is disabled. Default: false.
+ */
+ disabled?: boolean;
+
+ /*
+ * The number of milliseconds until a newly inserted item expires. Default: Number.MAX_VALUE.
+ */
+ maxAge?: number;
+
+ /*
+ * Determines how often a cache will scan for expired items when in aggressive mode. Default: 1000 (milliseconds).
+ */
+ recycleFreq?: number;
+
+ /*
+ * If inserting a promise into a cache, also insert the rejection value if the promise rejects. Default: false.
+ */
+ storeOnReject?: boolean;
+
+ /*
+ * If inserting a promise into a cache, also insert the resolved value if the promise resolves. Default: false.
+ */
+ storeOnResolve?: boolean;
+
+ /*
+ * Provide a custom storage medium, e.g. a polyfill for localStorage. Default: null.
+ *
+ * Must implement:
+ *
+ * setItem - Same API as localStorage.setItem(key, value)
+ * getItem - Same API as localStorage.getItem(key)
+ * removeItem - Same API as localStorage.removeItem(key)
+ */
+ storageImpl?: IStoreImplementation;
+
+ /*
+ * Determines the storage medium used by a cache. Default: memory.
+ *
+ * Possible values:
+ *
+ * memory - cache will hold data in memory. Data is cleared when the page is refreshed.
+ * localStorage - cache will hold data in localStorage if available. Data is not cleared when the page is refreshed.
+ * sessionStorage - cache will hold data in sessionStorage if available. Data is not cleared when the page is refreshed.
+ */
+ storageMode?: string;
+
+ /*
+ * Determines the namespace of a cache when storageMode is set to localStorage or sessionStorage. Make it a shorter
+ * string to save space. Default: angular-cache.caches.
+ */
+ storagePrefix?: string;
+
+ /*
+ * A callback function to be executed whenever an expired item is removed from a cache when the cache is in passive
+ * or aggressive mode. Will be passed the key and value of the expired item.
+ *
+ * Will be passed a third done argument if the cache is in passive mode. This allows you to synchronously access the
+ * key and value of the expired item when you make the cache#get(key[, options]) call that is the reason the expired
+ * item is being removed in the first place. Default: null.
+ */
+ onExpire?(key: string, value: any): any;
+ }
+
+ export interface ICache {
+
+ $$id: string;
+
+ /**
+ * Return the item with the given key.options, if provided, must be an object.
+ *
+ * If the cache is in passive mode, then options.onExpire can be a function that will be called with the key
+ * and value of the requested item if the requested item is expired, with the get call itself returning undefined.
+ * @param key
+ * @returns {}
+ */
+ get(key: string, options?: CacheGetOptions): T;
+
+ /**
+ * Insert the item with the given key and value into the cache.options, if provided, must be an object.
+ *
+ * If inserting a promise, options.storeOnReject determines whether to insert the rejection value if the promise
+ * rejects (overriding the default storeOnReject setting for the cache). If inserting a promise, options.storeOnResolve
+ * determines whether to insert the resolved value if the promise resolves (overriding the default storeOnResolve setting for the cache).
+ *
+ * @param key
+ * @param value
+ * @param options
+ */
+ put(key: string, value: T, options?: CachePutOptions): void;
+
+ /**
+ * Remove and return the item with the given key, if it is in the cache.
+ * @param key
+ * @returns {}
+ */
+ remove(key: string): T;
+
+ /**
+ * Remove all items in the cache.
+ */
+ removeAll(): void;
+
+ /**
+ * Remove and return all expired items in the cache.
+ * @returns {}
+ */
+ removeExpired(): { [key: string]: any };
+
+ /**
+ * Completely destroy this cache and its data.
+ * @returns {}
+ */
+ destroy(): void;
+
+ /**
+ * Returns an object containing information about the cache.
+ *
+ * @param key
+ */
+ info(): CacheInfo;
+
+ /**
+ * Returns an object containing information about the item with the given key, if the item is in the cache.
+ *
+ * @param key
+ */
+ info(key: string): CacheItemInfo;
+
+ /**
+ * Return the keys of all items in the cache as an object.
+ * @returns {}
+ */
+ keySet(): any;
+
+ /**
+ * Return the keys of all items in the cache as an array.
+ * @returns []
+ */
+ keys(): Array;
+
+ /**
+ * Enable the cache.
+ */
+ enable(): void;
+
+ /**
+ * Disable the cache.
+ */
+ disable(): void;
+
+ /**
+ * cache#touch() will "touch" all items in the cache.
+ * cache#touch(key) will "touch" the item with the given key.
+ *
+ * @param key
+ */
+ touch(key?: string, options?: CacheTouchOptions): void;
+
+ /**
+ * Set the cacheFlushInterval for the cache.
+ * @param cacheFlushInterval
+ */
+ setCacheFlushInterval(cacheFlushInterval: number): void;
+
+ /**
+ * Set the capacity for the cache.Setting this lower than the current item count will result in those items being removed.
+ * @param capacity
+ */
+ setCapacity(capacity: number): void;
+
+ /**
+ * Set the deleteOnExpire for the cache.
+ * @param deleteOnExpire
+ */
+ setDeleteOnExpire(deleteOnExpire: string): void;
+
+ /**
+ * Set the maxAge for the cache.
+ */
+ setMaxAge(maxAge: number): void;
+
+ /**
+ * Set the onExpire for the cache.
+ * @param onExpire
+ */
+ setOnExpire(onExpire: Function): void;
+
+ /**
+ * Set the recycleFreq for the cache.
+ * @param recycleFreq
+ */
+ setRecycleFreq(recycleFreq: number): void;
+
+ /**
+ * Set the storageMode for the cache.This will move data from the current storage medium to the new one.
+ * @param storageMode
+ */
+ setStorageMode(storageMode: string): void;
+
+ /**
+ * Set multiple options for the cache at a time.Setting strict to true will reset options for the cache
+ * that are not specifically set in the options hash to CacheFactoryProvider.defaults.
+ * @param options
+ */
+ setOptions(options: CacheOptions, strict?: boolean): void;
+
+ /**
+ * Return the values of all items in the cache as an array.
+ * @returns Array
+ */
+ values(): Array
+ }
+
+ export interface ICacheFactory {
+
+ BinaryHeap: IBinaryHeap;
+ utils: IUtils;
+ defaults: CacheOptions;
+
+ /**
+ * Create a cache. cache must not already exist. cacheId must be a string. options is an optional argument and must be an object.
+ * Any options you pass here will override any default options.
+ * @param cacheId
+ * @param options
+ * @returns ICache
+ */
+ (cacheId: string, options?: CacheOptions): ICache;
+
+ /**
+ * Create a cache. cache must not already exist. cacheId must be a string. options is an optional argument and must be an object.
+ * Any options you pass here will override any default options.
+ * @param cacheId
+ * @param options
+ * @returns ICache
+ */
+ createCache(cacheId: string, options?: CacheOptions): ICache;
+
+ /**
+ * Return the cache with the given cacheId.
+ * @param cacheId The id of the cache storage.
+ * @returns ICache
+ */
+ get(cacheId: string, options?: CacheOptions): ICache;
+
+ /**
+ * Return an object of key- value pairs, the keys being cache ids and the values being the result of .info() being called on each cache.
+ * @returns CacheInfo
+ */
+ info(): CacheInfo;
+
+ /**
+ * Return the ids of all registered caches as an object.
+ * @returns {[key: string]: ICache}
+ */
+ keySet(): { [key: string]: ICache };
+
+ /**
+ * Return the ids of all registered caches as an array.
+ * @returns Array
+ */
+ keys(): Array;
+
+ /**
+ * Destroy the cache with the given cacheId.
+ * @param cacheId
+ */
+ destroy(cacheId: string): void;
+
+ /**
+ * Destroy all registered caches.
+ */
+ destroyAll(): void;
+
+ /**
+ * Remove all data from all registered caches.
+ */
+ clearAll(): void;
+
+ /**
+ * Enable all registered caches.
+ */
+ enableAll(): void;
+
+ /**
+ * Disable all registered caches.
+ */
+ disableAll(): void;
+
+ /**
+ * Call.touch() on all registered caches.
+ */
+ touchAll(): void;
+
+ /**
+ * Call.removeExpired() on all registered caches.Returns a hash of any expired items, keyed by cache id.
+ * @returns {}
+ */
+ removeExpiredFromAll(): Array<{ [key: string]: Array<{ [key: string]: any }> }>;
+ }
+
+ export interface IUtils {
+ isNumber(value: any): boolean;
+ isString(value: any): boolean;
+ isObject(value: any): boolean;
+ isFunction(value: any): boolean;
+ equals(a: any, b: any): boolean;
+ fromJson(value: any): {}
+ Promise: any;
+ }
+
+ export interface HeapItem {
+ key: string;
+ accessed: Date;
+ }
+
+ export interface IBinaryHeap {
+ (w?: IWeightFunc, c?: ICompareFunc): void;
+
+ heap: Array;
+ weightFunc: IWeightFunc;
+ compareFunc: ICompareFunc;
+
+ push(node: HeapItem): void;
+ pop(): HeapItem;
+ peek(): HeapItem;
+ remove(node: HeapItem): HeapItem;
+ removeAll(): void;
+ size(): Number;
+ }
+
+ export interface IWeightFunc {
+ (x: T): T;
+ }
+
+ export interface ICompareFunc {
+ (x: T, y: T): boolean;
+ }
+
+ export interface CacheInfo {
+ size: Number;
+ caches: { [key: string]: any };
+ capacity: Number;
+ maxAge: Number;
+ deleteOnExpire: string;
+ onExpire: Function;
+ cacheFlushInterval: Number;
+ recycleFreq: Number;
+ storageMode: string;
+ storageImpl: IStoreImplementation;
+ disabled: boolean;
+ storagePrefix: string;
+ storeOnResolve: boolean;
+ storeOnReject: boolean;
+ }
+
+ export interface CacheItemInfo {
+ created: Date;
+ accessed: Date;
+ expires: Date;
+ isExpired: boolean;
+ }
+}
+
+declare var CacheFactory: CacheFactory.ICacheFactory;
+
+declare module "cachefactory" {
+ export = CacheFactory;
+}
\ No newline at end of file
diff --git a/chartist/chartist.d.ts b/chartist/chartist.d.ts
index 6c679dc1d8..0e92364812 100644
--- a/chartist/chartist.d.ts
+++ b/chartist/chartist.d.ts
@@ -105,7 +105,7 @@ declare namespace Chartist {
plugins?: Array; // all of these plugins seem to be functions with options, but keeping type any for now
update(data: Object, options?: T, override?: boolean): void;
- detatch(): void;
+ detach(): void;
/**
* Use this function to register event handlers. The handler callbacks are synchronous and will run in the main thread rather than the event loop.
diff --git a/chrome/chrome-app.d.ts b/chrome/chrome-app.d.ts
index 1891b960e0..3b63357986 100644
--- a/chrome/chrome-app.d.ts
+++ b/chrome/chrome-app.d.ts
@@ -685,7 +685,7 @@ declare namespace chrome.usb {
interface DeviceEvent extends chrome.events.Event<(device: Device) => void> {}
export var onDeviceAdded: DeviceEvent;
- export var onDeviceAdded: DeviceEvent;
+ export var onDeviceRemoved: DeviceEvent;
export function getDevices(options: { vendorId?: number, productId?: number, filters?: DeviceFilter[] }, callback: (devices: Device[]) => void): void;
export function getUserSelectedDevices(options: { multiple?: boolean, filters?: DeviceFilter[] }, callback: (devices: Device[]) => void): void;
diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts
index cdb48b2767..bdd0271fca 100644
--- a/chrome/chrome.d.ts
+++ b/chrome/chrome.d.ts
@@ -6210,7 +6210,7 @@ declare namespace chrome.tabs {
* The tab's new favicon URL.
* @since Chrome 27.
*/
- faviconUrl?: string;
+ favIconUrl?: string;
/**
* The tab's new title.
* @since Chrome 48.
diff --git a/ckeditor/ckeditor.d.ts b/ckeditor/ckeditor.d.ts
index bba377090f..9d8728338f 100644
--- a/ckeditor/ckeditor.d.ts
+++ b/ckeditor/ckeditor.d.ts
@@ -641,7 +641,7 @@ declare namespace CKEDITOR {
filebrowserImageBrowseLinkUrl?: string;
filebrowserImageBrowseUrl?: string;
filebrowserImageUploadUrl?: string;
- filebrowserUploadUr?: string;
+ filebrowserUploadUrl?: string;
filebrowserWindowFeatures?: string;
filebrowserWindowHeight?: number | string;
filebrowserWindowWidth?: number | string;
diff --git a/co-views/co-views-tests.ts b/co-views/co-views-tests.ts
new file mode 100644
index 0000000000..7c05cecde6
--- /dev/null
+++ b/co-views/co-views-tests.ts
@@ -0,0 +1,26 @@
+///
+///
+
+import views = require('co-views');
+
+const render = views('views', {
+ map: {
+ html: 'swig'
+ },
+ default: 'jade'
+});
+
+const fileName = 'xxx'; // template file name
+const locals = {}; // template locals data
+
+async function test() {
+ const html = await render(fileName, locals);
+ console.log(html);
+}
+
+// or use generator
+
+// function* test() {
+// const html = yield render(fileName, locals);
+// console.log(html);
+// }
diff --git a/co-views/co-views.d.ts b/co-views/co-views.d.ts
new file mode 100644
index 0000000000..66de5fbf79
--- /dev/null
+++ b/co-views/co-views.d.ts
@@ -0,0 +1,68 @@
+// Type definitions for co-views v2.1
+// Project: https://github.com/tj/co-views/
+// Definitions by: devlee
+// Definitions: https://github.com/devlee/DefinitelyTyped
+
+/* =================== USAGE ===================
+
+ import views = require('co-views');
+ const render = views('views', {
+ map: {
+ html: 'swig'
+ },
+ default: 'jade'
+ });
+
+ =============================================== */
+
+declare module "co-views" {
+
+ interface EngineMap {
+ /**
+ * use for .html files
+ */
+ html: string
+ }
+
+ interface CoViewsOptions {
+
+ /**
+ * default extname
+ */
+ ext?: string,
+
+ /**
+ * default extname
+ */
+ default?: string,
+
+ /**
+ * engine map
+ */
+ map?: EngineMap,
+
+ /**
+ * proxy partials
+ */
+ partials?: Object,
+
+ /**
+ * cache compiled templates
+ */
+ cache?: boolean,
+
+ /**
+ * common locals data
+ */
+ locals?: Object
+ }
+
+ /**
+ * Pass views `dir` and `opts` to return a render function.
+ */
+ function views(dir?: string, opts?: CoViewsOptions): {
+ (view: string, locals?: Object): any
+ };
+
+ export = views;
+}
diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts
index bade422821..b1bf33e2d2 100644
--- a/codemirror/codemirror.d.ts
+++ b/codemirror/codemirror.d.ts
@@ -181,7 +181,7 @@ declare namespace CodeMirror {
handle: any;
text: string;
/** Object mapping gutter IDs to marker elements. */
- gutterMarks: any;
+ gutterMarkers: any;
textClass: string;
bgClass: string;
wrapClass: string;
@@ -220,14 +220,7 @@ declare namespace CodeMirror {
/** Get an { left , top , width , height , clientWidth , clientHeight } object that represents the current scroll position, the size of the scrollable area,
and the size of the visible area(minus scrollbars). */
- getScrollInfo(): {
- left: any;
- top: any;
- width: any;
- height: any;
- clientWidth: any;
- clientHeight: any;
- }
+ getScrollInfo(): CodeMirror.ScrollInfo;
/** Scrolls the given element into view. pos is a { line , ch } position, referring to a given character, null, to refer to the cursor.
The margin parameter is optional. When given, it indicates the amount of pixels around the given area that should be made visible as well. */
@@ -609,6 +602,15 @@ declare namespace CodeMirror {
text: string;
}
+ interface ScrollInfo {
+ left: any;
+ top: any;
+ width: any;
+ height: any;
+ clientWidth: any;
+ clientHeight: any;
+ }
+
interface TextMarker {
/** Remove the mark. */
clear(): void;
@@ -1125,6 +1127,115 @@ declare namespace CodeMirror {
severity?: string;
to?: Position;
}
+
+ /**
+ * A function that calculates either a two-way or three-way merge between different sets of content.
+ */
+ function MergeView(element: HTMLElement, options?: MergeView.MergeViewEditorConfiguration): MergeView.MergeViewEditor;
+
+ namespace MergeView {
+ /**
+ * Options available to MergeView.
+ */
+ interface MergeViewEditorConfiguration extends EditorConfiguration {
+ /**
+ * Determines whether the original editor allows editing. Defaults to false.
+ */
+ allowEditingOriginals?: boolean;
+
+ /**
+ * When true stretches of unchanged text will be collapsed. When a number is given, this indicates the amount
+ * of lines to leave visible around such stretches (which defaults to 2). Defaults to false.
+ */
+ collapseIdentical?: boolean | number;
+
+ /**
+ * Sets the style used to connect changed chunks of code. By default, connectors are drawn. When this is set to "align",
+ * the smaller chunk is padded to align with the bigger chunk instead.
+ */
+ connect?: string;
+
+ /**
+ * Callback for when stretches of unchanged text are collapsed.
+ */
+ onCollapse?(mergeView: MergeViewEditor, line: number, size: number, mark: TextMarker): void;
+
+ /**
+ * Provides original version of the document to be shown on the right of the editor.
+ */
+ orig: any;
+
+ /**
+ * Provides original version of the document to be shown on the left of the editor.
+ * To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight.
+ */
+ origLeft?: any;
+
+ /**
+ * Provides original version of document to be shown on the right of the editor.
+ * To create a 2-way (as opposed to 3-way) merge view, provide only one of origLeft and origRight.
+ */
+ origRight?: any;
+
+ /**
+ * Determines whether buttons that allow the user to revert changes are shown. Defaults to true.
+ */
+ revertButtons?: boolean;
+
+ /**
+ * When true, changed pieces of text are highlighted. Defaults to true.
+ */
+ showDifferences?: boolean;
+ }
+
+ interface MergeViewEditor extends Editor {
+ /**
+ * Returns the editor instance.
+ */
+ editor(): Editor;
+
+ /**
+ * Left side of the merge view.
+ */
+ left: DiffView;
+ leftChunks(): MergeViewDiffChunk;
+ leftOriginal(): Editor;
+
+ /**
+ * Right side of the merge view.
+ */
+ right: DiffView;
+ rightChunks(): MergeViewDiffChunk;
+ rightOriginal(): Editor;
+
+ /**
+ * Sets whether or not the merge view should show the differences between the editor views.
+ */
+ setShowDifferences(showDifferences: boolean): void;
+ }
+
+ /**
+ * Tracks changes in chunks from oroginal to new.
+ */
+ interface MergeViewDiffChunk {
+ editFrom: number;
+ editTo: number;
+ origFrom: number;
+ origTo: number;
+ }
+
+ interface DiffView {
+ /**
+ * Forces the view to reload.
+ */
+ forceUpdate(): (mode: string) => void;
+
+ /**
+ * Sets whether or not the merge view should show the differences between the editor views.
+ */
+ setShowDifferences(showDifferences: boolean): void;
+ }
+ }
}
declare module "codemirror" {
diff --git a/combokeys/combokeys-tests.ts b/combokeys/combokeys-tests.ts
new file mode 100644
index 0000000000..1a065861ff
--- /dev/null
+++ b/combokeys/combokeys-tests.ts
@@ -0,0 +1,33 @@
+
+///
+
+import Combokeys = require("combokeys");
+
+const combokeys1: Combokeys.Combokeys = new Combokeys(document.createElement('div'));
+const combokeys2: Combokeys.Combokeys = new Combokeys(document.createElement('div'));
+
+combokeys1.bind('ctrl+a', () => {});
+combokeys1.bind('ctrl+z', () => {}, 'keydown');
+combokeys1.bind(['ctrl+a', 'ctrl+shift+a'], () => {});
+combokeys1.bind(['ctrl+a', 'ctrl+shift+a'], () => {}, 'keyup');
+
+combokeys1.bindMultiple(['ctrl+a', 'ctrl+shift+a'], () => {});
+combokeys1.bindMultiple(['ctrl+a', 'ctrl+shift+a'], () => {}, 'keyup');
+
+const result: boolean = combokeys1.stopCallback(new Event(null), document.createElement('div'));
+
+combokeys1.unbind('ctrl+a');
+combokeys1.unbind('ctrl+a', 'keydown');
+combokeys1.unbind(['ctrl+a', 'ctrl+shift+a']);
+combokeys1.unbind(['ctrl+a', 'ctrl+shift+a'], 'keydown');
+
+combokeys1.trigger('ctrl+a');
+combokeys1.trigger('ctrl+a', 'keypress');
+
+combokeys1.reset();
+
+combokeys1.detach();
+
+Combokeys.reset();
+
+Combokeys.instances.forEach((combokeys: Combokeys.Combokeys) => combokeys.reset() );
diff --git a/combokeys/combokeys.d.ts b/combokeys/combokeys.d.ts
new file mode 100644
index 0000000000..f7e1e5b035
--- /dev/null
+++ b/combokeys/combokeys.d.ts
@@ -0,0 +1,107 @@
+// Type definitions for Combokeys v2.4.6
+// Project: https://github.com/PolicyStat/combokeys
+// Definitions by: Ian Clanton-Thuon
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare namespace Combokeys {
+ interface CombokeysStatic {
+ new (element: Element): Combokeys;
+
+ /**
+ * all instances of Combokeys
+ */
+ instances: Combokeys[];
+
+ /**
+ * reset all instances
+ */
+ reset(): void;
+ }
+
+ interface Combokeys {
+ element: Element;
+
+ /**
+ * binds an event to Combokeys
+ *
+ * can be a single key, a combination of keys separated with +,
+ * an array of keys, or a sequence of keys separated by spaces
+ *
+ * be sure to list the modifier keys first to make sure that the
+ * correct key ends up getting bound (the last key in the pattern)
+ *
+ * @param {keys} key combination or combinations
+ * @param {callback} callback function
+ * @param {handler} optional - one of "keypress", "keydown", or "keyup"
+ * @returns void
+ */
+ bind(keys: string | string[], callback: () => void, action?: string): void;
+
+
+ /**
+ * binds multiple combinations to the same callback
+ *
+ * @param {keys} key combinations
+ * @param {callback} callback function
+ * @param {handler} optional - one of "keypress", "keydown", or "keyup"
+ * @returns void
+ */
+ bindMultiple(keys: string[], callback: () => void, action?: string): void;
+
+ /**
+ * unbinds an event to Combokeys
+ *
+ * the unbinding sets the callback function of the specified key combo
+ * to an empty function and deletes the corresponding key in the
+ * directMap dict.
+ *
+ * the keycombo+action has to be exactly the same as
+ * it was defined in the bind method
+ *
+ * @param {keys} key combination or combinations
+ * @param {action} optional - one of "keypress", "keydown", or "keyup"
+ * @returns void
+ */
+ unbind(keys: string | string[], action?: string): void;
+
+ /**
+ * triggers an event that has already been bound
+ *
+ * @param {keys} key combination
+ * @param {action} optional - one of "keypress", "keydown", or "keyup"
+ * @returns void
+ */
+ trigger(keys: string, action?: string): void;
+
+ /**
+ * resets the library back to its initial state. This is useful
+ * if you want to clear out the current keyboard shortcuts and bind
+ * new ones - for example if you switch to another page
+ *
+ * @returns void
+ */
+ reset(): void;
+
+ /**
+ * should we stop this event before firing off callbacks
+ *
+ * @param {e} event
+ * @param {element} bound element
+ * @return {boolean}
+ */
+ stopCallback(e: Event, element: Element): boolean;
+
+ /**
+ * detach all listners from the bound element
+ *
+ * @return {void}
+ */
+ detach(): void;
+ }
+}
+
+declare var combokeys: Combokeys.CombokeysStatic;
+
+declare module "combokeys" {
+ export = combokeys;
+}
diff --git a/common-tags/common-tags-tests.ts b/common-tags/common-tags-tests.ts
new file mode 100644
index 0000000000..9114f4414c
--- /dev/null
+++ b/common-tags/common-tags-tests.ts
@@ -0,0 +1,156 @@
+///
+
+import * as commonTags from 'common-tags';
+
+/* Test Built-in Tags */
+
+commonTags.commaLists `
+ I like ${['apples', 'bananas', 'watermelons']}
+ They're good!
+`;
+
+commonTags.commaListsAnd`
+ I like ${['apples', 'bananas', 'watermelons']}
+ They're good!
+`;
+
+commonTags.commaListsOr`
+ I like ${['apples', 'bananas', 'watermelons']}
+ They're good!
+`;
+
+let fruits = ['apple', 'orange', 'watermelon'];
+
+commonTags.html`
+
+
+ ${fruits.map(fruit => `- ${fruit}
`)}
+ ${'- kiwi
\n- guava
'}
+
+
+`;
+
+commonTags.codeBlock`
+
+
+ ${fruits.map(fruit => `- ${fruit}
`)}
+ ${'- kiwi
\n- guava
'}
+
+
+`;
+
+commonTags.source`
+
+
+ ${fruits.map(fruit => `- ${fruit}
`)}
+ ${'- kiwi
\n- guava
'}
+
+
+`;
+
+commonTags.oneLine`
+ foo
+ bar
+ baz
+`;
+
+commonTags.oneLineTrim`
+ https://news.com/article
+ ?utm_source=designernews.co
+`;
+
+commonTags.oneLineCommaLists`
+ I like ${['apples', 'bananas', 'watermelons']}
+ They're good!
+`;
+
+commonTags.oneLineCommaListsOr`
+ I like ${['apples', 'bananas', 'watermelons']}
+ They're good!
+`;
+
+commonTags.oneLineCommaListsAnd`
+ I like ${['apples', 'bananas', 'watermelons']}
+ They're good!
+`;
+
+commonTags.inlineLists`
+ I like ${['apples', 'bananas', 'watermelons']}
+ They're good!
+`;
+
+commonTags.oneLineInlineLists`
+ I like ${['apples', 'bananas', 'watermelons']}
+ They're good!
+`;
+
+let verb = 'notice';
+
+commonTags.stripIndent`
+ This is a multi-line string.
+ You'll ${verb} that it is indented.
+ We don't want to output this indentation.
+ But we do want to keep this line indented.
+`;
+
+commonTags.stripIndents`
+ This is a multi-line string.
+ You'll ${verb} that it is indented.
+ We don't want to output this indentation.
+ We don't want to keep this line indented either.
+`;
+
+/* Test Tag Constructor */
+
+new commonTags.TemplateTag();
+
+const substitutionReplacer = (oldValue : string, newValue : string) => ({
+ onSubstitution(substitution : string, resultSoFar : string) {
+ if (substitution === oldValue) {
+ return newValue;
+ }
+ return substitution;
+ }
+});
+
+new commonTags.TemplateTag(substitutionReplacer('fizz', 'buzz'));
+
+new commonTags.TemplateTag(
+ substitutionReplacer('fizz', 'buzz'),
+ substitutionReplacer('foo', 'bar')
+);
+
+new commonTags.TemplateTag([
+ substitutionReplacer('fizz', 'buzz'),
+ substitutionReplacer('foo', 'bar')
+]);
+
+new commonTags.TemplateTag({});
+
+new commonTags.TemplateTag({
+ onEndResult: endResult => `${endResult}!`
+});
+
+new commonTags.TemplateTag({
+ onSubstitution: substitution => `${substitution}!`,
+ onEndResult: endResult => `${endResult}!`
+});
+
+/* Tests Built-in Transformers */
+
+new commonTags.TemplateTag(commonTags.trimResultTransformer());
+new commonTags.TemplateTag(commonTags.trimResultTransformer('left'));
+new commonTags.TemplateTag(commonTags.trimResultTransformer('right'));
+
+new commonTags.TemplateTag(commonTags.stripIndentTransformer());
+new commonTags.TemplateTag(commonTags.stripIndentTransformer('initial'));
+new commonTags.TemplateTag(commonTags.stripIndentTransformer('all'));
+
+new commonTags.TemplateTag(commonTags.replaceResultTransformer('foo', 'bar'));
+
+new commonTags.TemplateTag(commonTags.inlineArrayTransformer());
+new commonTags.TemplateTag(commonTags.inlineArrayTransformer({}));
+new commonTags.TemplateTag(commonTags.inlineArrayTransformer({separator: 'foo'}));
+new commonTags.TemplateTag(commonTags.inlineArrayTransformer({conjunction: 'bar'}));
+
+new commonTags.TemplateTag(commonTags.splitStringTransformer('foo'));
diff --git a/common-tags/common-tags.d.ts b/common-tags/common-tags.d.ts
new file mode 100644
index 0000000000..aa443ac33d
--- /dev/null
+++ b/common-tags/common-tags.d.ts
@@ -0,0 +1,62 @@
+// Type definitions for common-tags v1.2.1
+// Project: https://github.com/declandewet/common-tags
+// Definitions by: Viktor Zozuliak
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+declare module 'common-tags' {
+ type TemplateTag = (literals: string[], ...placeholders: any[]) => string;
+
+ type TemplateTransformer = {
+ onSubstitution?: (substitution: string, resultSoFar: string) => string;
+ onEndResult?: (endResult : string) => string;
+ }
+
+ /* Built-in Tags */
+ export var commaLists: TemplateTag;
+
+ export var commaListsAnd: TemplateTag;
+
+ export var commaListsOr: TemplateTag;
+
+ export var html: TemplateTag;
+
+ export var codeBlock: TemplateTag;
+
+ export var source: TemplateTag;
+
+ export var oneLine: TemplateTag;
+
+ export var oneLineTrim: TemplateTag;
+
+ export var oneLineCommaLists: TemplateTag;
+
+ export var oneLineCommaListsOr: TemplateTag;
+
+ export var oneLineCommaListsAnd: TemplateTag;
+
+ export var inlineLists: TemplateTag;
+
+ export var oneLineInlineLists: TemplateTag;
+
+ export var stripIndent: TemplateTag;
+
+ export var stripIndents: TemplateTag;
+
+ /* New Tag Constructor */
+ export var TemplateTag: {
+ new(): TemplateTag;
+ new(...transformers: TemplateTransformer[]): TemplateTag;
+ new(transformers: TemplateTransformer[]): TemplateTag;
+ };
+
+ /* Built-in Transformers */
+ export var trimResultTransformer: (side?: 'left'|'right') => TemplateTransformer;
+
+ export var stripIndentTransformer: (type?: 'initial'|'all') => TemplateTransformer;
+
+ export var replaceResultTransformer: (replaceWhat: string, replaceWith: string) => TemplateTransformer;
+
+ export var inlineArrayTransformer: (opts?: {separator?: string, conjunction?: string}) => TemplateTransformer;
+
+ export var splitStringTransformer: (splitBy: string) => TemplateTransformer;
+}
diff --git a/component-emitter/component-emitter-tests.ts b/component-emitter/component-emitter-tests.ts
new file mode 100644
index 0000000000..e6c6a5b1ab
--- /dev/null
+++ b/component-emitter/component-emitter-tests.ts
@@ -0,0 +1,52 @@
+/// // only for require
+///
+// These are all of the examples from https://www.npmjs.com/package/component-emitter as of June 18, 2016
+
+
+// These are all of the examples from https://www.npmjs.com/package/component-emitter as of June 18, 2016
+
+var Emitter = require('component-emitter');
+var emitter = new Emitter;
+emitter.emit('something');
+
+
+
+
+var user = { name: 'tobi' };
+Emitter(user);
+
+(user).emit('im a user');
+
+
+
+// this example modified from the one on https://www.npmjs.com/package/component-emitter
+var User = Object.create({
+ someUserFunction: () => {console.log('someUserFunction called!')}
+})
+var another_user = Emitter(User);
+another_user.someUserFunction()
+another_user.on('hi', () => {console.log('Hi called')})
+another_user.emit('hi')
+
+
+// Additional sample code for this test
+function handleSomeRecurringEvent(event_data: any) {
+ console.log('handle some-recurring-event')
+}
+emitter.on('some-recurring-event', handleSomeRecurringEvent)
+
+
+emitter.once('some-single-shot-event', (event_data: any) => {console.log('handle some-single-shot-event')})
+
+
+emitter.off()
+emitter.off('some-recurring-event')
+emitter.off('some-recurring-event', handleSomeRecurringEvent)
+
+var event_data = {some: 'data'}
+emitter.emit('some-recurring-event')
+emitter.emit('some-recurring-event', event_data)
+
+emitter.listeners('some-recurring-event')
+
+emitter.hasListeners('some-recurring-event')
diff --git a/component-emitter/component-emitter.d.ts b/component-emitter/component-emitter.d.ts
new file mode 100644
index 0000000000..28ce4f4bc9
--- /dev/null
+++ b/component-emitter/component-emitter.d.ts
@@ -0,0 +1,19 @@
+// Type definitions for component-emitter v1.2.1
+// Project: https://www.npmjs.com/package/component-emitter
+// Definitions by: Peter Snider
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/emitter-component
+
+
+interface Emitter {
+ (obj?: Object): Emitter;
+ on(event: string, listener: Function): Emitter;
+ once(event: string, listener: Function): Emitter;
+ off(event?: string, listener?: Function): Emitter;
+ emit(event: string, ...args: any[]): boolean;
+ listeners(event: string): Function[];
+ hasListeners(event: string): boolean;
+}
+
+declare module 'component-emitter' {
+ var Emitter: Emitter;
+}
diff --git a/cordova/cordova.d.ts b/cordova/cordova.d.ts
index 299e2da4d9..a830fa4881 100644
--- a/cordova/cordova.d.ts
+++ b/cordova/cordova.d.ts
@@ -35,7 +35,7 @@ interface Cordova {
* @param action The action name to call on the native side (generally corresponds to the native class method).
* @param args An array of arguments to pass into the native environment.
*/
- exec(success: () => any, fail: () => any, service: string, action: string, args?: string[]): void;
+ exec(success: (data: any) => any, fail: (err: any) => any, service: string, action: string, args?: any[]): void;
/** Gets the operating system name. */
platformId: string;
/** Gets Cordova framework version */
diff --git a/cordova/plugins/NetworkInformation.d.ts b/cordova/plugins/NetworkInformation.d.ts
index 4f80fdbb7e..0d49597e3a 100644
--- a/cordova/plugins/NetworkInformation.d.ts
+++ b/cordova/plugins/NetworkInformation.d.ts
@@ -47,6 +47,7 @@ interface Connection {
*/
type: string;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
declare var Connection: {
diff --git a/core-js/core-js-tests.ts b/core-js/core-js-tests.ts
index bc690d434c..965acc6855 100644
--- a/core-js/core-js-tests.ts
+++ b/core-js/core-js-tests.ts
@@ -500,3 +500,5 @@ s = s.unescapeHTML();
// #############################################################################################
promiseOfVoid = delay(i);
+
+console.log('core-js version number:', core.version);
diff --git a/core-js/core-js.d.ts b/core-js/core-js.d.ts
index 16441df233..e9be316364 100644
--- a/core-js/core-js.d.ts
+++ b/core-js/core-js.d.ts
@@ -790,8 +790,17 @@ interface PromiseConstructor {
* @param values An array of Promises.
* @returns A new Promise.
*/
- all(values: Iterable>): Promise;
-
+ all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
+ all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike