From 1137ef6d1096716ae6941ed526a0e94606aa0741 Mon Sep 17 00:00:00 2001 From: thorn0 Date: Thu, 1 Oct 2015 23:39:24 +0300 Subject: [PATCH] AngularJS: Fix the signature for angular.bootstrap see https://code.angularjs.org/1.4.0/docs/api/ng/function/angular.bootstrap --- angularjs/angular-tests.ts | 27 ++++++-- angularjs/angular.d.ts | 136 +++---------------------------------- 2 files changed, 29 insertions(+), 134 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 0174a0d61..c00bd4d22 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -387,31 +387,31 @@ module TestPromise { var tresult: TResult; var tresultPromise: ng.IPromise; - + var tother: TOther; var totherPromise: ng.IPromise; - + var promise: angular.IPromise; // promise.then result = >promise.then((result) => any); result = >promise.then((result) => any, (any) => any); result = >promise.then((result) => any, (any) => any, (any) => any); - + result = >promise.then((result) => result); result = >promise.then((result) => result, (any) => any); result = >promise.then((result) => result, (any) => any, (any) => any); result = >promise.then((result) => tresultPromise); result = >promise.then((result) => tresultPromise, (any) => any); result = >promise.then((result) => tresultPromise, (any) => any, (any) => any); - + result = >promise.then((result) => tother); result = >promise.then((result) => tother, (any) => any); result = >promise.then((result) => tother, (any) => any, (any) => any); result = >promise.then((result) => totherPromise); result = >promise.then((result) => totherPromise, (any) => any); result = >promise.then((result) => totherPromise, (any) => any, (any) => any); - + // promise.catch result = >promise.catch((err) => any); result = >promise.catch((err) => tresult); @@ -937,7 +937,7 @@ function NgModelControllerTyping() { function ngFilterTyping() { var $filter: angular.IFilterService; var items: string[]; - + $filter("name")(items, "test"); $filter("name")(items, {name: "test"}); $filter("name")(items, (val, index, array) => { @@ -948,4 +948,19 @@ function ngFilterTyping() { }, (actual, expected) => { return actual == expected; }); +} + +function doBootstrap(element: Element | JQuery, mode: string): ng.auto.IInjectorService { + if (mode === 'debug') { + return angular.bootstrap(element, ['main', function($provide: ng.auto.IProvideService) { + $provide.decorator('$rootScope', function($delegate: ng.IRootScopeService) { + $delegate['debug'] = true; + }); + }, 'debug-helpers'], { + debugInfoEnabled: true + }); + } + return angular.bootstrap(element, ['main'], { + debugInfoEnabled: false + }); } \ No newline at end of file diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 9f7fa07b0..725729752 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -41,6 +41,7 @@ declare module angular { interface IAngularBootstrapConfig { strictDi?: boolean; + debugInfoEnabled?: boolean; } /////////////////////////////////////////////////////////////////////////// @@ -56,132 +57,11 @@ declare module angular { * @param element DOM element which is the root of angular application. * @param modules An array of modules to load into the application. * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. + * function that will be invoked by the injector as a config block. * @param config an object for defining configuration options for the application. The following keys are supported: * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. */ - bootstrap(element: string, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: string, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: string, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: JQuery, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: JQuery, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: JQuery, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: Element, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: Element, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: Element, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: Document, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: Document, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; - /** - * Use this function to manually start up angular application. - * - * @param element DOM element which is the root of angular application. - * @param modules An array of modules to load into the application. - * Each item in the array should be the name of a predefined module or a (DI annotated) - * function that will be invoked by the injector as a run block. - * @param config an object for defining configuration options for the application. The following keys are supported: - * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. - */ - bootstrap(element: Document, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; + bootstrap(element: string|Element|JQuery, modules?: (string|Function|any[])[], config?: IAngularBootstrapConfig): auto.IInjectorService; /** * Creates a deep copy of source, which should be an object or an array. @@ -674,7 +554,7 @@ declare module angular { */ $odd: boolean; - } + } interface IAngularEvent { /** @@ -784,19 +664,19 @@ declare module angular { */ (name: string): IFilterFunc; } - + interface IFilterFunc { (array: T[], expression: string | IFilterPatternObject | IFilterPredicateFunc, comparator?: IFilterComparatorFunc|boolean): T[]; } - + interface IFilterPatternObject { [name: string]: string; } - + interface IFilterPredicateFunc { (value: T, index: number, array: T[]): T[]; } - + interface IFilterComparatorFunc { (actual: T, expected: T): boolean; }