From 7e059afe0fc6567df343d178af52d52e00b923ed Mon Sep 17 00:00:00 2001 From: LaserUnicorns Date: Fri, 31 Mar 2017 19:45:48 +0300 Subject: [PATCH] Revert "[angular-material] updated resolve object typings in dialog, toast, etc" --- .../angular-material-tests.ts | 96 +++++++------------ types/angular-material/index.d.ts | 67 +++++++------ types/angular-material/tslint.json | 7 -- 3 files changed, 69 insertions(+), 101 deletions(-) delete mode 100644 types/angular-material/tslint.json diff --git a/types/angular-material/angular-material-tests.ts b/types/angular-material/angular-material-tests.ts index da898cfc13..f9195ec999 100644 --- a/types/angular-material/angular-material-tests.ts +++ b/types/angular-material/angular-material-tests.ts @@ -1,12 +1,15 @@ -const myApp = angular.module('testModule', ['ngMaterial']); + + +var myApp = angular.module('testModule', ['ngMaterial']); myApp.config(( $mdThemingProvider: ng.material.IThemingProvider, $mdIconProvider: ng.material.IIconProvider, $mdProgressCircularProvider: ng.material.IProgressCircularProvider) => { + $mdThemingProvider.alwaysWatchTheme(true); - const neonRedMap: ng.material.IPalette = $mdThemingProvider.extendPalette('red', { - 500: 'ff0000' + var neonRedMap: ng.material.IPalette = $mdThemingProvider.extendPalette('red', { + '500': 'ff0000' }); // Register the new color palette map with the name neonRed $mdThemingProvider.definePalette('neonRed', neonRedMap); @@ -18,10 +21,10 @@ myApp.config(( .warnPalette('red') .dark(true); - const browserColors: ng.material.IBrowserColors = { - theme: 'default', - palette: 'neonRed', - hue: '500' + var browserColors: ng.material.IBrowserColors = { + theme: 'default', + palette: 'neonRed', + hue: '500' }; $mdThemingProvider.enableBrowserColor(browserColors); @@ -42,19 +45,14 @@ myApp.config(( }); }); -myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng.material.IBottomSheetService, $q: ng.IQService) => { +myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng.material.IBottomSheetService) => { $scope['openBottomSheet'] = () => { $mdBottomSheet.show({ template: 'Hello!', clickOutsideToClose: true, disableBackdrop: true, disableParentScroll: false, - resolve: { - r1: () => $q.resolve(), - r2: () => Promise.resolve(), - r3: ['fakeService', (fake) => $q.resolve()], - r4: ['fakeService', (fake) => Promise.resolve()], - } + parent: () => {} }); }; $scope['hideBottomSheet'] = $mdBottomSheet.hide.bind($mdBottomSheet, 'hide'); @@ -62,10 +60,10 @@ myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng }); myApp.controller('ColorController', ($scope: ng.IScope, $mdColor: ng.material.IColorService) => { - let colorExpression: ng.material.IColorExpression; - let element: Element; + var colorExpression : ng.material.IColorExpression; + var element : Element; - colorExpression = { color: '#FFFFFF' }; + colorExpression = { color: '#FFFFFF' } element = new Element(); @@ -73,23 +71,17 @@ myApp.controller('ColorController', ($scope: ng.IScope, $mdColor: ng.material.IC $mdColor.applyThemeColors(element, colorExpression); }; $scope['getThemeColor'] = () => { - $mdColor.getThemeColor('default-neonRed'); + $mdColor.getThemeColor('default-neonRed') }; $scope['hasTheme'] = () => { $mdColor.hasTheme(); }; }); -myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.IDialogService, $q: ng.IQService) => { +myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.IDialogService) => { $scope['openDialog'] = () => { $mdDialog.show({ - template: 'Hello!', - resolve: { - r1: () => $q.resolve(), - r2: () => Promise.resolve(), - r3: ['fakeService', (fake) => $q.resolve()], - r4: ['fakeService', (fake) => Promise.resolve()], - } + template: 'Hello!' }); }; $scope['alertDialog'] = () => { @@ -117,12 +109,7 @@ myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material. $mdDialog.show($mdDialog.prompt().placeholder('Prompt input placeholder text')); }; $scope['promptDialog'] = () => { - $mdDialog.show($mdDialog.prompt().initialValue('Buddy').resolve({ - r1: () => $q.resolve(), - r2: () => Promise.resolve(), - r3: ['fakeService', (fake) => $q.resolve()], - r4: ['fakeService', (fake) => Promise.resolve()], - })); + $mdDialog.show($mdDialog.prompt().initialValue('Buddy')); }; $scope['prerenderedDialog'] = () => { $mdDialog.show({ @@ -136,12 +123,13 @@ myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material. }); class IconDirective implements ng.IDirective { + private $mdIcon: ng.material.IIcon; constructor($mdIcon: ng.material.IIcon) { this.$mdIcon = $mdIcon; } - link($scope: ng.IScope, $elm: ng.IAugmentedJQuery) { + public link($scope: ng.IScope, $elm: ng.IAugmentedJQuery) { this.$mdIcon('android').then((iconEl: Element) => $elm.append(iconEl)); this.$mdIcon('work:chair').then((iconEl: Element) => $elm.append(iconEl)); // Load and cache the external SVG using a URL @@ -162,7 +150,7 @@ myApp.controller('MediaController', ($scope: ng.IScope, $mdMedia: ng.material.IM }); myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.material.ISidenavService) => { - const componentId = 'left'; + var componentId = 'left'; $scope['toggle'] = () => $mdSidenav(componentId).toggle(); $scope['open'] = () => $mdSidenav(componentId).open(); $scope['close'] = () => $mdSidenav(componentId).close(); @@ -177,53 +165,41 @@ myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.materia instance.isLockedOpen(); }); - $scope['onClose'] = $mdSidenav(componentId).onClose(() => { }); + $scope['onClose'] = $mdSidenav(componentId).onClose(() => {}); }); -myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService, $q: ng.IQService) => { +myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService) => { $scope['openToast'] = () => { $mdToast.show($mdToast.simple().textContent('Hello!')); $mdToast.updateTextContent('New Content'); - }; + } $scope['customToast'] = () => { - const options: ng.material.IToastOptions = { + var options = { hideDelay: 3000, position: 'top right', - controller: 'ToastCtrl', - templateUrl: 'toast-template.html', - toastClass: 'my-class', - resolve: { - r1: () => $q.resolve(), - r2: () => Promise.resolve(), - r3: ['fakeService', (fake) => $q.resolve()], - r4: ['fakeService', (fake) => Promise.resolve()], - } + controller : 'ToastCtrl', + templateUrl : 'toast-template.html', + toastClass: 'my-class' }; $mdToast.show(options); - }; + } }); -myApp.controller('PanelController', ($scope: ng.IScope, $mdPanel: ng.material.IPanelService, $q: ng.IQService) => { +myApp.controller('PanelController', ($scope: ng.IScope, $mdPanel: ng.material.IPanelService) => { $scope['createPanel'] = () => { - const config: ng.material.IPanelConfig = { + var config = { id: 'myPanel', template: '

Hello!

', hasBackdrop: true, disableParentScroll: true, - zIndex: 150, - resolve: { - r1: () => $q.resolve(), - r2: () => Promise.resolve(), - r3: ['fakeService', (fake) => $q.resolve()], - r4: ['fakeService', (fake) => Promise.resolve()], - } + zIndex: 150 }; - + $mdPanel.create(config); - let panelRef = $mdPanel.create(config); + var panelRef = $mdPanel.create(config); panelRef.open() .then((ref: ng.material.IPanelRef) => { ref.addClass('foo'); @@ -256,6 +232,6 @@ myApp.controller('PanelController', ($scope: ng.IScope, $mdPanel: ng.material.IP $scope['newPanelAnimation'] = () => { $mdPanel.newPanelAnimation().openFrom('.some-target'); - $mdPanel.newPanelAnimation().openFrom({ top: 0, left: 0 }); + $mdPanel.newPanelAnimation().openFrom({top: 0, left: 0}); }; }); diff --git a/types/angular-material/index.d.ts b/types/angular-material/index.d.ts index fff8a0a085..a8196269a4 100644 --- a/types/angular-material/index.d.ts +++ b/types/angular-material/index.d.ts @@ -9,25 +9,21 @@ declare var _: string; export = _; declare module 'angular' { - namespace material { - interface ResolveObject { - [index: string]: angular.Injectable<(...args: any[]) => PromiseLike>; - } - + export namespace material { interface IBottomSheetOptions { templateUrl?: string; template?: string; scope?: angular.IScope; // default: new child scope preserveScope?: boolean; // default: false - controller?: string | ((...args: any[]) => any); + controller?: string | Function; locals?: { [index: string]: any }; clickOutsideToClose?: boolean; bindToController?: boolean; // default: false disableBackdrop?: boolean; escapeToClose?: boolean; - resolve?: ResolveObject; + resolve?: { [index: string]: () => angular.IPromise }; controllerAs?: string; - parent?: string | Element | JQuery | ((scope: ng.IScope, element: JQuery, options: IBottomSheetOptions) => Element | JQuery); // default: root node + parent?: Function | string | Object; // default: root node disableParentScroll?: boolean; // default: true } @@ -53,16 +49,16 @@ declare module 'angular' { clickOutsideToClose(clickOutsideToClose?: boolean): T; // default: false escapeToClose(escapeToClose?: boolean): T; // default: true focusOnOpen(focusOnOpen?: boolean): T; // default: true - controller(controller?: string | ((...args: any[]) => any)): T; + controller(controller?: string | Function): T; locals(locals?: { [index: string]: any }): T; bindToController(bindToController?: boolean): T; // default: false - resolve(resolve?: ResolveObject): T; + resolve(resolve?: { [index: string]: () => angular.IPromise }): T; controllerAs(controllerAs?: string): T; parent(parent?: string | Element | JQuery): T; // default: root node + onComplete(onComplete?: Function): T; ariaLabel(ariaLabel: string): T; } - // tslint:disable-next-line no-empty-interface interface IAlertDialog extends IPresetDialog { } @@ -101,15 +97,15 @@ declare module 'angular' { clickOutsideToClose?: boolean; // default: false escapeToClose?: boolean; // default: true focusOnOpen?: boolean; // default: true - controller?: string | ((...args: any[]) => any); + controller?: string | Function; locals?: { [index: string]: any }; bindToController?: boolean; // default: false - resolve?: ResolveObject; + resolve?: { [index: string]: () => angular.IPromise } controllerAs?: string; parent?: string | Element | JQuery; // default: root node - onShowing?(scope: ng.IScope, element: JQuery): void; - onComplete?(scope: ng.IScope, element: JQuery): void; - onRemoving?(element: JQuery, action: ng.IPromise): void; + onShowing?: Function; + onComplete?: Function; + onRemoving?: Function; skipHide?: boolean; multiple?: boolean; fullscreen?: boolean; // default: false @@ -124,7 +120,9 @@ declare module 'angular' { cancel(response?: any): void; } - type IIcon = (id: string) => angular.IPromise; // id is a unique ID or URL + interface IIcon { + (id: string): angular.IPromise; // id is a unique ID or URL + } interface IIconProvider { icon(id: string, url: string, viewBoxSize?: number): IIconProvider; // viewBoxSize default: 24 @@ -134,7 +132,9 @@ declare module 'angular' { defaultFontSet(name: string): IIconProvider; } - type IMedia = (media: string) => boolean; + interface IMedia { + (media: string): boolean; + } interface ISidenavObject { toggle(): angular.IPromise; @@ -142,7 +142,7 @@ declare module 'angular' { close(): angular.IPromise; isOpen(): boolean; isLockedOpen(): boolean; - onClose(onClose: () => void): void; + onClose(onClose: Function): void; } interface ISidenavService { @@ -163,7 +163,6 @@ declare module 'angular' { toastClass(toastClass: string): T; } - // tslint:disable-next-line no-empty-interface interface ISimpleToastPreset extends IToastPreset { } @@ -176,10 +175,10 @@ declare module 'angular' { hideDelay?: number | false; // default (ms): 3000 position?: string; // any combination of 'bottom'/'left'/'top'/'right'/'fit'; default: 'bottom left' toastClass?: string; - controller?: string | ((...args: any[]) => any); + controller?: string | Function; locals?: { [index: string]: any }; bindToController?: boolean; // default: false - resolve?: ResolveObject; + resolve?: { [index: string]: () => angular.IPromise } controllerAs?: string; parent?: string | Element | JQuery; // default: root node } @@ -264,19 +263,19 @@ declare module 'angular' { interface IThemeConfig { disableTheming: boolean; - generateOnDemand: boolean; + generateOnDemand: boolean; nonce: string; defaultTheme: string; alwaysWatchTheme: boolean; - registeredStyles: string[]; + registeredStyles: Array; } interface IThemingProvider { alwaysWatchTheme(alwaysWatch: boolean): void; definePalette(name: string, palette: IPalette): IThemingProvider; - enableBrowserColor(browserColors: IBrowserColors): () => void; + enableBrowserColor(browserColors: IBrowserColors): Function; extendPalette(name: string, palette: IPalette): IPalette; - registerStyles(styles: string): void; + registerStyles(styles: String): void; setDefaultTheme(theme: string): void; setNonce(nonce: string): void; theme(name: string, inheritFrom?: string): ITheme; @@ -329,11 +328,11 @@ declare module 'angular' { id?: string; template?: string; templateUrl?: string; - controller?: string | ((...args: any[]) => any); + controller?: string | Function; controllerAs?: string; bindToController?: boolean; // default: true locals?: { [index: string]: any }; - resolve?: ResolveObject; + resolve?: { [index: string]: () => angular.IPromise } attachTo?: string | JQuery | Element; propagateContainerEvents?: boolean; panelClass?: string; @@ -347,10 +346,10 @@ declare module 'angular' { animation?: IPanelAnimation; hasBackdrop?: boolean; // default: false disableParentScroll?: boolean; // default: false - onDomAdded?(...args: any[]): void; - onOpenComplete?(...args: any[]): void; - onRemoving?(...args: any[]): void; - onDomRemoved?(...args: any[]): void; + onDomAdded?: Function; + onOpenComplete?: Function; + onRemoving?: Function; + onDomRemoved?: Function; origin?: string | JQuery | Element; onCloseSuccess?: ((panel: IPanelRef, closeReason: string) => any); } @@ -443,11 +442,11 @@ declare module 'angular' { progressSize?: number; strokeWidth?: number; duration?: number; - easeFn?(t: number, b: number, c: number, d: number): number; + easeFn?: Function; durationIndeterminate?: number; startIndeterminate?: number; endIndeterminate?: number; - easeFnIndeterminate?(t: number, b: number, c: number, d: number): number; + easeFnIndeterminate?: Function; } interface IProgressCircularProvider { diff --git a/types/angular-material/tslint.json b/types/angular-material/tslint.json deleted file mode 100644 index 5783b495dd..0000000000 --- a/types/angular-material/tslint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../tslint.json", - "rules": { - "interface-name": false, - "max-line-length": false - } -}