diff --git a/CODING_STANDARDS.md b/CODING_STANDARDS.md index 947caa5f802c..c8a0e7221e6a 100644 --- a/CODING_STANDARDS.md +++ b/CODING_STANDARDS.md @@ -274,21 +274,13 @@ For example: ```ts @Input() disabled: boolean; get disabled(): boolean { return this._disabled; } -set disabled(v: boolean) { this._disabled = coerceBooleanProperty(v); } +set disabled(v: BooleanInput) { this._disabled = coerceBooleanProperty(v); } private _disabled = false; - -... - -static ngAcceptInputType_value: BooleanInput; ``` The above code allows users to set `disabled` similar to how it can be set on native inputs: ```html ``` -Even though an empty string is technically what is being provided as the value of `disabled`, -`ngAcceptInputType` allows the mismatched type to be provided and `coerceBooleanProperty` -interprets the given value (an empty string) to the correct type & value, which in this case would -be `true`. #### Expose native inputs Native inputs used in components should be exposed to developers through `ng-content`. This allows diff --git a/src/cdk-experimental/combobox/combobox.ts b/src/cdk-experimental/combobox/combobox.ts index 7e6c2cc9d9cb..049576ea199b 100644 --- a/src/cdk-experimental/combobox/combobox.ts +++ b/src/cdk-experimental/combobox/combobox.ts @@ -70,7 +70,7 @@ export class CdkCombobox implements OnDestroy, AfterContentInit { get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled: boolean = false; @@ -79,7 +79,7 @@ export class CdkCombobox implements OnDestroy, AfterContentInit { get openActions(): OpenAction[] { return this._openActions; } - set openActions(action: OpenAction[]) { + set openActions(action: OpenActionInput) { this._openActions = this._coerceOpenActionProperty(action); } private _openActions: OpenAction[] = ['click']; @@ -89,7 +89,7 @@ export class CdkCombobox implements OnDestroy, AfterContentInit { get autoSetText(): boolean { return this._autoSetText; } - set autoSetText(value: boolean) { + set autoSetText(value: BooleanInput) { this._autoSetText = coerceBooleanProperty(value); } private _autoSetText: boolean = true; @@ -287,18 +287,14 @@ export class CdkCombobox implements OnDestroy, AfterContentInit { return this._panelContent; } - private _coerceOpenActionProperty(input: string | OpenAction[]): OpenAction[] { + private _coerceOpenActionProperty(input: OpenActionInput): OpenAction[] { let actions = typeof input === 'string' ? input.trim().split(/[ ,]+/) : input; if ( (typeof ngDevMode === 'undefined' || ngDevMode) && - actions.some(a => allowedOpenActions.indexOf(a) === -1) + actions?.some(a => allowedOpenActions.indexOf(a) === -1) ) { throw Error(`${input} is not a support open action for CdkCombobox`); } return actions as OpenAction[]; } - - static ngAcceptInputType_openActions: OpenActionInput; - static ngAcceptInputType_autoSetText: OpenActionInput; - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/cdk-experimental/listbox/listbox.ts b/src/cdk-experimental/listbox/listbox.ts index e29b8fbfc401..6f15c1ff67c5 100644 --- a/src/cdk-experimental/listbox/listbox.ts +++ b/src/cdk-experimental/listbox/listbox.ts @@ -74,7 +74,7 @@ export class CdkOption implements ListKeyManagerOption, Highlightab get selected(): boolean { return this._selected; } - set selected(value: boolean) { + set selected(value: BooleanInput) { if (!this._disabled) { this._selected = coerceBooleanProperty(value); } @@ -84,7 +84,7 @@ export class CdkOption implements ListKeyManagerOption, Highlightab get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } @@ -198,9 +198,6 @@ export class CdkOption implements ListKeyManagerOption, Highlightab setInactiveStyles() { this._active = false; } - - static ngAcceptInputType_selected: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } @Directive({ @@ -261,16 +258,17 @@ export class CdkListbox implements AfterContentInit, OnDestroy, OnInit, Contr get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { - this._updateSelectionOnMultiSelectionChange(value); - this._multiple = coerceBooleanProperty(value); + set multiple(value: BooleanInput) { + const coercedValue = coerceBooleanProperty(value); + this._updateSelectionOnMultiSelectionChange(coercedValue); + this._multiple = coercedValue; } @Input() get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } @@ -279,7 +277,7 @@ export class CdkListbox implements AfterContentInit, OnDestroy, OnInit, Contr get useActiveDescendant(): boolean { return this._useActiveDescendant; } - set useActiveDescendant(shouldUseActiveDescendant: boolean) { + set useActiveDescendant(shouldUseActiveDescendant: BooleanInput) { this._useActiveDescendant = coerceBooleanProperty(shouldUseActiveDescendant); } @@ -288,7 +286,7 @@ export class CdkListbox implements AfterContentInit, OnDestroy, OnInit, Contr get autoFocus(): boolean { return this._autoFocus; } - set autoFocus(shouldAutoFocus: boolean) { + set autoFocus(shouldAutoFocus: BooleanInput) { this._autoFocus = coerceBooleanProperty(shouldAutoFocus); } @@ -553,11 +551,6 @@ export class CdkListbox implements AfterContentInit, OnDestroy, OnInit, Contr } } } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_multiple: BooleanInput; - static ngAcceptInputType_useActiveDescendant: BooleanInput; - static ngAcceptInputType_autoFocus: BooleanInput; } /** Change event that is being fired whenever the selected state of an option changes. */ diff --git a/src/cdk-experimental/menu/context-menu.ts b/src/cdk-experimental/menu/context-menu.ts index ba97d7a98746..cb291ad6b6d9 100644 --- a/src/cdk-experimental/menu/context-menu.ts +++ b/src/cdk-experimental/menu/context-menu.ts @@ -114,10 +114,10 @@ export class CdkContextMenuTrigger implements OnDestroy { /** Whether the context menu should be disabled. */ @Input('cdkContextMenuDisabled') - get disabled() { + get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; @@ -326,6 +326,4 @@ export class CdkContextMenuTrigger implements OnDestroy { this._menuPanel._menuStack = null; } } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/cdk-experimental/menu/menu-item-selectable.ts b/src/cdk-experimental/menu/menu-item-selectable.ts index 59207253e065..d6073454c75f 100644 --- a/src/cdk-experimental/menu/menu-item-selectable.ts +++ b/src/cdk-experimental/menu/menu-item-selectable.ts @@ -25,10 +25,10 @@ export abstract class CdkMenuItemSelectable extends CdkMenuItem { /** Whether the element is checked */ @Input() - get checked() { + get checked(): boolean { return this._checked; } - set checked(value: boolean) { + set checked(value: BooleanInput) { this._checked = coerceBooleanProperty(value); } private _checked = false; @@ -45,6 +45,4 @@ export abstract class CdkMenuItemSelectable extends CdkMenuItem { this.toggled.next(this); } } - - static ngAcceptInputType_checked: BooleanInput; } diff --git a/src/cdk-experimental/menu/menu-item.ts b/src/cdk-experimental/menu/menu-item.ts index 8ae61cf087fa..e7f8acb5caa9 100644 --- a/src/cdk-experimental/menu/menu-item.ts +++ b/src/cdk-experimental/menu/menu-item.ts @@ -66,7 +66,7 @@ export class CdkMenuItem implements FocusableOption, FocusableElement, Toggler, get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; @@ -259,6 +259,4 @@ export class CdkMenuItem implements FocusableOption, FocusableElement, Toggler, ngOnDestroy() { this._destroyed.next(); } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts b/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts index 4116402000ca..016058c9fdba 100644 --- a/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts +++ b/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts @@ -472,7 +472,7 @@ export class CdkAutoSizeVirtualScroll implements OnChanges { get minBufferPx(): number { return this._minBufferPx; } - set minBufferPx(value: number) { + set minBufferPx(value: NumberInput) { this._minBufferPx = coerceNumberProperty(value); } _minBufferPx = 100; @@ -487,7 +487,7 @@ export class CdkAutoSizeVirtualScroll implements OnChanges { get maxBufferPx(): number { return this._maxBufferPx; } - set maxBufferPx(value: number) { + set maxBufferPx(value: NumberInput) { this._maxBufferPx = coerceNumberProperty(value); } _maxBufferPx = 200; @@ -498,7 +498,4 @@ export class CdkAutoSizeVirtualScroll implements OnChanges { ngOnChanges() { this._scrollStrategy.updateBufferSize(this.minBufferPx, this.maxBufferPx); } - - static ngAcceptInputType_minBufferPx: NumberInput; - static ngAcceptInputType_maxBufferPx: NumberInput; } diff --git a/src/cdk-experimental/selection/row-selection.ts b/src/cdk-experimental/selection/row-selection.ts index 9516bea4dd06..faae627bba2c 100644 --- a/src/cdk-experimental/selection/row-selection.ts +++ b/src/cdk-experimental/selection/row-selection.ts @@ -32,12 +32,10 @@ export class CdkRowSelection { get index(): number | undefined { return this._index; } - set index(index: number | undefined) { + set index(index: NumberInput) { this._index = coerceNumberProperty(index); } protected _index?: number; constructor(readonly _selection: CdkSelection) {} - - static ngAcceptInputType_index: NumberInput; } diff --git a/src/cdk-experimental/selection/selection-toggle.ts b/src/cdk-experimental/selection/selection-toggle.ts index 7f2a8d1c2f33..14f7f62d222f 100644 --- a/src/cdk-experimental/selection/selection-toggle.ts +++ b/src/cdk-experimental/selection/selection-toggle.ts @@ -37,7 +37,7 @@ export class CdkSelectionToggle implements OnDestroy, OnInit { get index(): number | undefined { return this._index; } - set index(index: number | undefined) { + set index(index: NumberInput) { this._index = coerceNumberProperty(index); } protected _index?: number; @@ -96,6 +96,4 @@ export class CdkSelectionToggle implements OnDestroy, OnInit { private _isSelected(): boolean { return this._selection.isSelected(this.value, this.index); } - - static ngAcceptInputType_index: NumberInput; } diff --git a/src/cdk-experimental/selection/selection.ts b/src/cdk-experimental/selection/selection.ts index 5f7d128ee460..15089716f7ea 100644 --- a/src/cdk-experimental/selection/selection.ts +++ b/src/cdk-experimental/selection/selection.ts @@ -54,7 +54,7 @@ export class CdkSelection implements OnInit, AfterContentChecked, CollectionV get multiple(): boolean { return this._multiple; } - set multiple(multiple: boolean) { + set multiple(multiple: BooleanInput) { this._multiple = coerceBooleanProperty(multiple); } protected _multiple: boolean; @@ -217,8 +217,6 @@ export class CdkSelection implements OnInit, AfterContentChecked, CollectionV } selectAllState: SelectAllState = 'none'; - - static ngAcceptInputType_multiple: BooleanInput; } type SelectAllState = 'all' | 'none' | 'partial'; diff --git a/src/cdk/a11y/focus-trap/focus-trap.ts b/src/cdk/a11y/focus-trap/focus-trap.ts index 36577fc0d003..970c779ea2c0 100644 --- a/src/cdk/a11y/focus-trap/focus-trap.ts +++ b/src/cdk/a11y/focus-trap/focus-trap.ts @@ -417,7 +417,7 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit, OnChanges, DoC get enabled(): boolean { return this.focusTrap.enabled; } - set enabled(value: boolean) { + set enabled(value: BooleanInput) { this.focusTrap.enabled = coerceBooleanProperty(value); } @@ -429,7 +429,7 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit, OnChanges, DoC get autoCapture(): boolean { return this._autoCapture; } - set autoCapture(value: boolean) { + set autoCapture(value: BooleanInput) { this._autoCapture = coerceBooleanProperty(value); } private _autoCapture: boolean; @@ -488,7 +488,4 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit, OnChanges, DoC this._previouslyFocusedElement = _getFocusedElementPierceShadowDom(); this.focusTrap.focusInitialElementWhenReady(); } - - static ngAcceptInputType_enabled: BooleanInput; - static ngAcceptInputType_autoCapture: BooleanInput; } diff --git a/src/cdk/accordion/accordion-item.ts b/src/cdk/accordion/accordion-item.ts index 55db00818839..2a2366ebd16a 100644 --- a/src/cdk/accordion/accordion-item.ts +++ b/src/cdk/accordion/accordion-item.ts @@ -63,7 +63,7 @@ export class CdkAccordionItem implements OnDestroy { get expanded(): boolean { return this._expanded; } - set expanded(expanded: boolean) { + set expanded(expanded: BooleanInput) { expanded = coerceBooleanProperty(expanded); // Only emit events and update the internal value if the value changes. @@ -95,7 +95,7 @@ export class CdkAccordionItem implements OnDestroy { get disabled(): boolean { return this._disabled; } - set disabled(disabled: boolean) { + set disabled(disabled: BooleanInput) { this._disabled = coerceBooleanProperty(disabled); } private _disabled = false; @@ -166,7 +166,4 @@ export class CdkAccordionItem implements OnDestroy { } }); } - - static ngAcceptInputType_expanded: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/cdk/accordion/accordion.ts b/src/cdk/accordion/accordion.ts index 9a34cd3e3083..3127c869a67a 100644 --- a/src/cdk/accordion/accordion.ts +++ b/src/cdk/accordion/accordion.ts @@ -43,7 +43,7 @@ export class CdkAccordion implements OnDestroy, OnChanges { get multi(): boolean { return this._multi; } - set multi(multi: boolean) { + set multi(multi: BooleanInput) { this._multi = coerceBooleanProperty(multi); } private _multi: boolean = false; @@ -68,6 +68,4 @@ export class CdkAccordion implements OnDestroy, OnChanges { this._stateChanges.complete(); this._openCloseAllActions.complete(); } - - static ngAcceptInputType_multi: BooleanInput; } diff --git a/src/cdk/coercion/coercion.md b/src/cdk/coercion/coercion.md index de31cf23b359..bdb27f4b4c0f 100644 --- a/src/cdk/coercion/coercion.md +++ b/src/cdk/coercion/coercion.md @@ -25,7 +25,7 @@ class MyButton { // It also allows for a string to be passed like ``. @Input() get disabled() { return this._disabled; } - set disabled(value: any) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; @@ -37,7 +37,7 @@ class MyButton { // parsed to a number. @Input() get greetDelay() { return this._greetDelay; } - set greetDelay(value: any) { + set greetDelay(value: NumberInput) { this._greetDelay = coerceNumberProperty(value, 0); } private _greetDelay = 0; @@ -51,9 +51,5 @@ class MyButton { getElement(elementOrRef: ElementRef | HTMLElement): HTMLElement { return coerceElement(elementOrRef); } - - // Required so that the template type checker can infer the type of the coerced inputs. - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_greetDelay: NumberInput; } ``` diff --git a/src/cdk/drag-drop/directives/drag-handle.ts b/src/cdk/drag-drop/directives/drag-handle.ts index 58db302f0b45..0cf5223ba97e 100644 --- a/src/cdk/drag-drop/directives/drag-handle.ts +++ b/src/cdk/drag-drop/directives/drag-handle.ts @@ -48,7 +48,7 @@ export class CdkDragHandle implements OnDestroy { get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._stateChanges.next(this); } @@ -68,6 +68,4 @@ export class CdkDragHandle implements OnDestroy { ngOnDestroy() { this._stateChanges.complete(); } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/cdk/drag-drop/directives/drag-preview.ts b/src/cdk/drag-drop/directives/drag-preview.ts index 7d1e2fa177c2..64f189d8924a 100644 --- a/src/cdk/drag-drop/directives/drag-preview.ts +++ b/src/cdk/drag-drop/directives/drag-preview.ts @@ -33,12 +33,10 @@ export class CdkDragPreview { get matchSize(): boolean { return this._matchSize; } - set matchSize(value: boolean) { + set matchSize(value: BooleanInput) { this._matchSize = coerceBooleanProperty(value); } private _matchSize = false; constructor(public templateRef: TemplateRef) {} - - static ngAcceptInputType_matchSize: BooleanInput; } diff --git a/src/cdk/drag-drop/directives/drag.ts b/src/cdk/drag-drop/directives/drag.ts index a494509a0001..5a4341f1dbd9 100644 --- a/src/cdk/drag-drop/directives/drag.ts +++ b/src/cdk/drag-drop/directives/drag.ts @@ -123,7 +123,7 @@ export class CdkDrag implements AfterViewInit, OnChanges, OnDestroy { get disabled(): boolean { return this._disabled || (this.dropContainer && this.dropContainer.disabled); } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._dragRef.disabled = this._disabled; } @@ -574,6 +574,4 @@ export class CdkDrag implements AfterViewInit, OnChanges, OnDestroy { handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle); }); } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/cdk/drag-drop/directives/drop-list-group.ts b/src/cdk/drag-drop/directives/drop-list-group.ts index 14662ea48b77..fe4bece12a19 100644 --- a/src/cdk/drag-drop/directives/drop-list-group.ts +++ b/src/cdk/drag-drop/directives/drop-list-group.ts @@ -38,7 +38,7 @@ export class CdkDropListGroup implements OnDestroy { get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; @@ -46,6 +46,4 @@ export class CdkDropListGroup implements OnDestroy { ngOnDestroy() { this._items.clear(); } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/cdk/drag-drop/directives/drop-list.ts b/src/cdk/drag-drop/directives/drop-list.ts index 5171880840af..f03c30a1311b 100644 --- a/src/cdk/drag-drop/directives/drop-list.ts +++ b/src/cdk/drag-drop/directives/drop-list.ts @@ -114,7 +114,7 @@ export class CdkDropList implements OnDestroy { get disabled(): boolean { return this._disabled || (!!this._group && this._group.disabled); } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { // Usually we sync the directive and ref state right before dragging starts, in order to have // a single point of failure and to avoid having to use setters for everything. `disabled` is // a special case, because it can prevent the `beforeStarted` event from firing, which can lock @@ -125,7 +125,7 @@ export class CdkDropList implements OnDestroy { /** Whether sorting within this drop list is disabled. */ @Input('cdkDropListSortingDisabled') - sortingDisabled: boolean; + sortingDisabled: BooleanInput; /** * Function that is used to determine whether an item @@ -140,11 +140,11 @@ export class CdkDropList implements OnDestroy { /** Whether to auto-scroll the view when the user moves their pointer close to the edges. */ @Input('cdkDropListAutoScrollDisabled') - autoScrollDisabled: boolean; + autoScrollDisabled: BooleanInput; /** Number of pixels to scroll for each frame when auto-scrolling an element. */ @Input('cdkDropListAutoScrollStep') - autoScrollStep: number; + autoScrollStep: NumberInput; /** Emits when the user drops an item inside the container. */ @Output('cdkDropListDropped') @@ -394,9 +394,4 @@ export class CdkDropList implements OnDestroy { private _syncItemsWithRef() { this._dropListRef.withItems(this.getSortedItems().map(item => item._dragRef)); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_sortingDisabled: BooleanInput; - static ngAcceptInputType_autoScrollDisabled: BooleanInput; - static ngAcceptInputType_autoScrollStep: NumberInput; } diff --git a/src/cdk/observers/observe-content.ts b/src/cdk/observers/observe-content.ts index 2abd6e9d8f42..e390c89b7884 100644 --- a/src/cdk/observers/observe-content.ts +++ b/src/cdk/observers/observe-content.ts @@ -149,10 +149,10 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy { * to disconnect the underlying MutationObserver until it is needed. */ @Input('cdkObserveContentDisabled') - get disabled() { + get disabled(): boolean { return this._disabled; } - set disabled(value: any) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._disabled ? this._unsubscribe() : this._subscribe(); } @@ -163,7 +163,7 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy { get debounce(): number { return this._debounce; } - set debounce(value: number) { + set debounce(value: NumberInput) { this._debounce = coerceNumberProperty(value); this._subscribe(); } @@ -205,9 +205,6 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy { private _unsubscribe() { this._currentSubscription?.unsubscribe(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_debounce: NumberInput; } @NgModule({ diff --git a/src/cdk/overlay/overlay-directives.ts b/src/cdk/overlay/overlay-directives.ts index d9e1ba4156ee..cfbb6909d888 100644 --- a/src/cdk/overlay/overlay-directives.ts +++ b/src/cdk/overlay/overlay-directives.ts @@ -185,46 +185,46 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges { /** Whether or not the overlay should attach a backdrop. */ @Input('cdkConnectedOverlayHasBackdrop') - get hasBackdrop() { + get hasBackdrop(): boolean { return this._hasBackdrop; } - set hasBackdrop(value: any) { + set hasBackdrop(value: BooleanInput) { this._hasBackdrop = coerceBooleanProperty(value); } /** Whether or not the overlay should be locked when scrolling. */ @Input('cdkConnectedOverlayLockPosition') - get lockPosition() { + get lockPosition(): boolean { return this._lockPosition; } - set lockPosition(value: any) { + set lockPosition(value: BooleanInput) { this._lockPosition = coerceBooleanProperty(value); } /** Whether the overlay's width and height can be constrained to fit within the viewport. */ @Input('cdkConnectedOverlayFlexibleDimensions') - get flexibleDimensions() { + get flexibleDimensions(): boolean { return this._flexibleDimensions; } - set flexibleDimensions(value: boolean) { + set flexibleDimensions(value: BooleanInput) { this._flexibleDimensions = coerceBooleanProperty(value); } /** Whether the overlay can grow after the initial open when flexible positioning is turned on. */ @Input('cdkConnectedOverlayGrowAfterOpen') - get growAfterOpen() { + get growAfterOpen(): boolean { return this._growAfterOpen; } - set growAfterOpen(value: boolean) { + set growAfterOpen(value: BooleanInput) { this._growAfterOpen = coerceBooleanProperty(value); } /** Whether the overlay can be pushed on-screen if none of the provided positions fit. */ @Input('cdkConnectedOverlayPush') - get push() { + get push(): boolean { return this._push; } - set push(value: boolean) { + set push(value: BooleanInput) { this._push = coerceBooleanProperty(value); } @@ -449,12 +449,6 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges { this._backdropSubscription.unsubscribe(); this._positionSubscription.unsubscribe(); } - - static ngAcceptInputType_hasBackdrop: BooleanInput; - static ngAcceptInputType_lockPosition: BooleanInput; - static ngAcceptInputType_flexibleDimensions: BooleanInput; - static ngAcceptInputType_growAfterOpen: BooleanInput; - static ngAcceptInputType_push: BooleanInput; } /** @docs-private */ diff --git a/src/cdk/portal/portal-directives.ts b/src/cdk/portal/portal-directives.ts index 4e957d7b294d..57cceb02a838 100644 --- a/src/cdk/portal/portal-directives.ts +++ b/src/cdk/portal/portal-directives.ts @@ -98,7 +98,7 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr return this._attachedPortal; } - set portal(portal: Portal | null) { + set portal(portal: Portal | null | undefined | '') { // Ignore the cases where the `portal` is set to a falsy value before the lifecycle hooks have // run. This handles the cases where the user might do something like `
` // and attach a portal programmatically in the parent component. When Angular does the first CD @@ -115,7 +115,7 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr super.attach(portal); } - this._attachedPortal = portal; + this._attachedPortal = portal || null; } /** Emits when a portal is attached to the outlet. */ @@ -237,8 +237,6 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr : nativeElement.parentNode! ) as HTMLElement; } - - static ngAcceptInputType_portal: Portal | null | undefined | ''; } /** diff --git a/src/cdk/scrolling/fixed-size-virtual-scroll.ts b/src/cdk/scrolling/fixed-size-virtual-scroll.ts index 542457bec5ba..5c255f7b1795 100644 --- a/src/cdk/scrolling/fixed-size-virtual-scroll.ts +++ b/src/cdk/scrolling/fixed-size-virtual-scroll.ts @@ -206,7 +206,7 @@ export class CdkFixedSizeVirtualScroll implements OnChanges { get itemSize(): number { return this._itemSize; } - set itemSize(value: number) { + set itemSize(value: NumberInput) { this._itemSize = coerceNumberProperty(value); } _itemSize = 20; @@ -219,7 +219,7 @@ export class CdkFixedSizeVirtualScroll implements OnChanges { get minBufferPx(): number { return this._minBufferPx; } - set minBufferPx(value: number) { + set minBufferPx(value: NumberInput) { this._minBufferPx = coerceNumberProperty(value); } _minBufferPx = 100; @@ -231,7 +231,7 @@ export class CdkFixedSizeVirtualScroll implements OnChanges { get maxBufferPx(): number { return this._maxBufferPx; } - set maxBufferPx(value: number) { + set maxBufferPx(value: NumberInput) { this._maxBufferPx = coerceNumberProperty(value); } _maxBufferPx = 200; @@ -246,8 +246,4 @@ export class CdkFixedSizeVirtualScroll implements OnChanges { ngOnChanges() { this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx); } - - static ngAcceptInputType_itemSize: NumberInput; - static ngAcceptInputType_minBufferPx: NumberInput; - static ngAcceptInputType_maxBufferPx: NumberInput; } diff --git a/src/cdk/scrolling/virtual-for-of.ts b/src/cdk/scrolling/virtual-for-of.ts index be8a57a4d77a..0a2def6a6557 100644 --- a/src/cdk/scrolling/virtual-for-of.ts +++ b/src/cdk/scrolling/virtual-for-of.ts @@ -141,10 +141,10 @@ export class CdkVirtualForOf * Setting the cache size to `0` will disable caching. Defaults to 20 templates. */ @Input() - get cdkVirtualForTemplateCacheSize() { + get cdkVirtualForTemplateCacheSize(): number { return this._viewRepeater.viewCacheSize; } - set cdkVirtualForTemplateCacheSize(size: number) { + set cdkVirtualForTemplateCacheSize(size: NumberInput) { this._viewRepeater.viewCacheSize = coerceNumberProperty(size); } @@ -392,6 +392,4 @@ export class CdkVirtualForOf index, }; } - - static ngAcceptInputType_cdkVirtualForTemplateCacheSize: NumberInput; } diff --git a/src/cdk/scrolling/virtual-scroll-viewport.ts b/src/cdk/scrolling/virtual-scroll-viewport.ts index ae49acbbcaba..8706cf4316cc 100644 --- a/src/cdk/scrolling/virtual-scroll-viewport.ts +++ b/src/cdk/scrolling/virtual-scroll-viewport.ts @@ -99,7 +99,7 @@ export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, O get appendOnly(): boolean { return this._appendOnly; } - set appendOnly(value: boolean) { + set appendOnly(value: BooleanInput) { this._appendOnly = coerceBooleanProperty(value); } private _appendOnly = false; @@ -461,6 +461,4 @@ export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, O this._totalContentWidth = this.orientation === 'horizontal' ? `${this._totalContentSize}px` : ''; } - - static ngAcceptInputType_appendOnly: BooleanInput; } diff --git a/src/cdk/stepper/stepper.ts b/src/cdk/stepper/stepper.ts index a605392c61ac..b2a0193e257a 100644 --- a/src/cdk/stepper/stepper.ts +++ b/src/cdk/stepper/stepper.ts @@ -154,7 +154,7 @@ export class CdkStep implements OnChanges { get editable(): boolean { return this._editable; } - set editable(value: boolean) { + set editable(value: BooleanInput) { this._editable = coerceBooleanProperty(value); } private _editable = true; @@ -164,7 +164,7 @@ export class CdkStep implements OnChanges { get optional(): boolean { return this._optional; } - set optional(value: boolean) { + set optional(value: BooleanInput) { this._optional = coerceBooleanProperty(value); } private _optional = false; @@ -174,7 +174,7 @@ export class CdkStep implements OnChanges { get completed(): boolean { return this._completedOverride == null ? this._getDefaultCompleted() : this._completedOverride; } - set completed(value: boolean) { + set completed(value: BooleanInput) { this._completedOverride = coerceBooleanProperty(value); } _completedOverride: boolean | null = null; @@ -188,7 +188,7 @@ export class CdkStep implements OnChanges { get hasError(): boolean { return this._customError == null ? this._getDefaultError() : this._customError; } - set hasError(value: boolean) { + set hasError(value: BooleanInput) { this._customError = coerceBooleanProperty(value); } private _customError: boolean | null = null; @@ -246,11 +246,6 @@ export class CdkStep implements OnChanges { // global options, or if they've explicitly set it through the `hasError` input. return this._stepperOptions.showError ?? this._customError != null; } - - static ngAcceptInputType_editable: BooleanInput; - static ngAcceptInputType_hasError: BooleanInput; - static ngAcceptInputType_optional: BooleanInput; - static ngAcceptInputType_completed: BooleanInput; } @Directive({ @@ -281,22 +276,22 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy { get linear(): boolean { return this._linear; } - set linear(value: boolean) { + set linear(value: BooleanInput) { this._linear = coerceBooleanProperty(value); } private _linear = false; /** The index of the selected step. */ @Input() - get selectedIndex() { + get selectedIndex(): number { return this._selectedIndex; } - set selectedIndex(index: number) { + set selectedIndex(index: NumberInput) { const newIndex = coerceNumberProperty(index); if (this.steps && this._steps) { // Ensure that the index can't be out of bounds. - if (!this._isValidIndex(index) && (typeof ngDevMode === 'undefined' || ngDevMode)) { + if (!this._isValidIndex(newIndex) && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw Error('cdkStepper: Cannot assign out-of-bounds value to `selectedIndex`.'); } @@ -307,7 +302,7 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy { !this._anyControlsInvalidOrPending(newIndex) && (newIndex >= this._selectedIndex || this.steps.toArray()[newIndex].editable) ) { - this._updateSelectedItemIndex(index); + this._updateSelectedItemIndex(newIndex); } } else { this._selectedIndex = newIndex; @@ -593,13 +588,6 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy { private _isValidIndex(index: number): boolean { return index > -1 && (!this.steps || index < this.steps.length); } - - static ngAcceptInputType_editable: BooleanInput; - static ngAcceptInputType_optional: BooleanInput; - static ngAcceptInputType_completed: BooleanInput; - static ngAcceptInputType_hasError: BooleanInput; - static ngAcceptInputType_linear: BooleanInput; - static ngAcceptInputType_selectedIndex: NumberInput; } /** diff --git a/src/cdk/table/can-stick.ts b/src/cdk/table/can-stick.ts index e5a0d0da94fa..1d59286ba959 100644 --- a/src/cdk/table/can-stick.ts +++ b/src/cdk/table/can-stick.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {coerceBooleanProperty} from '@angular/cdk/coercion'; +import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; /** @docs-private */ export type Constructor = new (...args: any[]) => T; @@ -46,7 +46,7 @@ export function mixinHasStickyInput>(base: T): CanStic get sticky(): boolean { return this._sticky; } - set sticky(v: boolean) { + set sticky(v: BooleanInput) { const prevValue = this._sticky; this._sticky = coerceBooleanProperty(v); this._hasStickyChanged = prevValue !== this._sticky; diff --git a/src/cdk/table/cell.ts b/src/cdk/table/cell.ts index 22bf3c9c93d9..218d9c5ab709 100644 --- a/src/cdk/table/cell.ts +++ b/src/cdk/table/cell.ts @@ -86,7 +86,7 @@ export class CdkColumnDef extends _CdkColumnDefBase implements CanStick { get stickyEnd(): boolean { return this._stickyEnd; } - set stickyEnd(v: boolean) { + set stickyEnd(v: BooleanInput) { const prevValue = this._stickyEnd; this._stickyEnd = coerceBooleanProperty(v); this._hasStickyChanged = prevValue !== this._stickyEnd; @@ -145,9 +145,6 @@ export class CdkColumnDef extends _CdkColumnDefBase implements CanStick { this._updateColumnCssClassName(); } } - - static ngAcceptInputType_sticky: BooleanInput; - static ngAcceptInputType_stickyEnd: BooleanInput; } /** Base class for the cells. Adds a CSS classname that identifies the column it renders in. */ diff --git a/src/cdk/table/row.ts b/src/cdk/table/row.ts index 1e2bd6bdd850..18ed5fbb5532 100644 --- a/src/cdk/table/row.ts +++ b/src/cdk/table/row.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {BooleanInput} from '@angular/cdk/coercion'; import { ChangeDetectionStrategy, Component, @@ -109,8 +108,6 @@ export class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick, O override ngOnChanges(changes: SimpleChanges): void { super.ngOnChanges(changes); } - - static ngAcceptInputType_sticky: BooleanInput; } // Boilerplate for applying mixins to CdkFooterRowDef. @@ -141,8 +138,6 @@ export class CdkFooterRowDef extends _CdkFooterRowDefBase implements CanStick, O override ngOnChanges(changes: SimpleChanges): void { super.ngOnChanges(changes); } - - static ngAcceptInputType_sticky: BooleanInput; } /** diff --git a/src/cdk/table/table.ts b/src/cdk/table/table.ts index 114da2fbc634..9effc47d5f24 100644 --- a/src/cdk/table/table.ts +++ b/src/cdk/table/table.ts @@ -425,7 +425,7 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes get multiTemplateDataRows(): boolean { return this._multiTemplateDataRows; } - set multiTemplateDataRows(v: boolean) { + set multiTemplateDataRows(v: BooleanInput) { this._multiTemplateDataRows = coerceBooleanProperty(v); // In Ivy if this value is set via a static attribute (e.g. ), @@ -445,7 +445,7 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes get fixedLayout(): boolean { return this._fixedLayout; } - set fixedLayout(v: boolean) { + set fixedLayout(v: BooleanInput) { this._fixedLayout = coerceBooleanProperty(v); // Toggling `fixedLayout` may change column widths. Sticky column styles should be recalculated. @@ -1314,9 +1314,6 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes this._isShowingNoDataRow = shouldShow; } - - static ngAcceptInputType_multiTemplateDataRows: BooleanInput; - static ngAcceptInputType_fixedLayout: BooleanInput; } /** Utility function that gets a merged list of the entries in an array and values of a Set. */ diff --git a/src/cdk/text-field/autosize.ts b/src/cdk/text-field/autosize.ts index 7ec45ff3bedf..3170259f2d64 100644 --- a/src/cdk/text-field/autosize.ts +++ b/src/cdk/text-field/autosize.ts @@ -64,7 +64,7 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy { get minRows(): number { return this._minRows; } - set minRows(value: number) { + set minRows(value: NumberInput) { this._minRows = coerceNumberProperty(value); this._setMinHeight(); } @@ -74,7 +74,7 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy { get maxRows(): number { return this._maxRows; } - set maxRows(value: number) { + set maxRows(value: NumberInput) { this._maxRows = coerceNumberProperty(value); this._setMaxHeight(); } @@ -84,7 +84,7 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy { get enabled(): boolean { return this._enabled; } - set enabled(value: boolean) { + set enabled(value: BooleanInput) { value = coerceBooleanProperty(value); // Only act if the actual value changed. This specifically helps to not run @@ -368,8 +368,4 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy { textarea.setSelectionRange(selectionStart, selectionEnd); } } - - static ngAcceptInputType_minRows: NumberInput; - static ngAcceptInputType_maxRows: NumberInput; - static ngAcceptInputType_enabled: BooleanInput; } diff --git a/src/cdk/tree/padding.ts b/src/cdk/tree/padding.ts index 117e0957a524..bf41d0ba9c5f 100644 --- a/src/cdk/tree/padding.ts +++ b/src/cdk/tree/padding.ts @@ -38,7 +38,7 @@ export class CdkTreeNodePadding implements OnDestroy { get level(): number { return this._level; } - set level(value: number) { + set level(value: NumberInput) { this._setLevelInput(value); } _level: number; @@ -107,7 +107,7 @@ export class CdkTreeNodePadding implements OnDestroy { * TS 4.0 doesn't allow properties to override accessors or vice-versa. * @docs-private */ - protected _setLevelInput(value: number) { + protected _setLevelInput(value: NumberInput) { // Set to null as the fallback value so that _setPadding can fall back to the node level if the // consumer set the directive as `cdkTreeNodePadding=""`. We still want to take this value if // they set 0 explicitly. @@ -135,6 +135,4 @@ export class CdkTreeNodePadding implements OnDestroy { this._indent = coerceNumberProperty(value); this._setPadding(); } - - static ngAcceptInputType_level: NumberInput; } diff --git a/src/cdk/tree/toggle.ts b/src/cdk/tree/toggle.ts index 87ffd46d025c..0fd9326b20ff 100644 --- a/src/cdk/tree/toggle.ts +++ b/src/cdk/tree/toggle.ts @@ -26,7 +26,7 @@ export class CdkTreeNodeToggle { get recursive(): boolean { return this._recursive; } - set recursive(value: boolean) { + set recursive(value: BooleanInput) { this._recursive = coerceBooleanProperty(value); } protected _recursive = false; @@ -40,6 +40,4 @@ export class CdkTreeNodeToggle { event.stopPropagation(); } - - static ngAcceptInputType_recursive: BooleanInput; } diff --git a/src/components-examples/material-experimental/mdc-form-field/mdc-form-field-custom-control/form-field-custom-control-example.ts b/src/components-examples/material-experimental/mdc-form-field/mdc-form-field-custom-control/form-field-custom-control-example.ts index 8896858b2436..e1e312a901c3 100644 --- a/src/components-examples/material-experimental/mdc-form-field/mdc-form-field-custom-control/form-field-custom-control-example.ts +++ b/src/components-examples/material-experimental/mdc-form-field/mdc-form-field-custom-control/form-field-custom-control-example.ts @@ -69,7 +69,7 @@ export class MyTelInput implements ControlValueAccessor, MatFormFieldControl` tag */ diff --git a/src/material-experimental/mdc-button/fab.ts b/src/material-experimental/mdc-button/fab.ts index d666aecbaa5e..9f5c6ab00bfd 100644 --- a/src/material-experimental/mdc-button/fab.ts +++ b/src/material-experimental/mdc-button/fab.ts @@ -79,13 +79,13 @@ const defaults = MAT_FAB_DEFAULT_OPTIONS_FACTORY(); export class MatFabButton extends MatButtonBase { override _isFab = true; - private _extended: boolean; get extended(): boolean { return this._extended; } - set extended(value: boolean) { + set extended(value: BooleanInput) { this._extended = coerceBooleanProperty(value); } + private _extended: boolean; constructor( elementRef: ElementRef, @@ -98,8 +98,6 @@ export class MatFabButton extends MatButtonBase { this._options = this._options || defaults; this.color = this.defaultColor = this._options!.color || defaults.color; } - - static ngAcceptInputType_extended: BooleanInput; } /** @@ -157,13 +155,13 @@ export class MatMiniFabButton extends MatButtonBase { export class MatFabAnchor extends MatAnchor { override _isFab = true; - private _extended: boolean; get extended(): boolean { return this._extended; } - set extended(value: boolean) { + set extended(value: BooleanInput) { this._extended = coerceBooleanProperty(value); } + private _extended: boolean; constructor( elementRef: ElementRef, @@ -176,8 +174,6 @@ export class MatFabAnchor extends MatAnchor { this._options = this._options || defaults; this.color = this.defaultColor = this._options!.color || defaults.color; } - - static ngAcceptInputType_extended: BooleanInput; } /** diff --git a/src/material-experimental/mdc-checkbox/checkbox.ts b/src/material-experimental/mdc-checkbox/checkbox.ts index b536779399b7..88ac48fd6116 100644 --- a/src/material-experimental/mdc-checkbox/checkbox.ts +++ b/src/material-experimental/mdc-checkbox/checkbox.ts @@ -124,7 +124,7 @@ export class MatCheckbox get checked(): boolean { return this._checked; } - set checked(checked) { + set checked(checked: BooleanInput) { this._checked = coerceBooleanProperty(checked); } private _checked = false; @@ -139,7 +139,7 @@ export class MatCheckbox get indeterminate(): boolean { return this._indeterminate; } - set indeterminate(indeterminate) { + set indeterminate(indeterminate: BooleanInput) { this._indeterminate = coerceBooleanProperty(indeterminate); this._syncIndeterminate(this._indeterminate); } @@ -150,7 +150,7 @@ export class MatCheckbox get required(): boolean { return this._required; } - set required(required) { + set required(required: BooleanInput) { this._required = coerceBooleanProperty(required); } private _required = false; @@ -160,7 +160,7 @@ export class MatCheckbox get disableRipple(): boolean { return this._disableRipple; } - set disableRipple(disableRipple: boolean) { + set disableRipple(disableRipple: BooleanInput) { this._disableRipple = coerceBooleanProperty(disableRipple); } private _disableRipple = false; @@ -391,10 +391,4 @@ export class MatCheckbox nativeCheckbox.nativeElement.indeterminate = value; } } - - static ngAcceptInputType_checked: BooleanInput; - static ngAcceptInputType_indeterminate: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_required: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } diff --git a/src/material-experimental/mdc-chips/chip-grid.ts b/src/material-experimental/mdc-chips/chip-grid.ts index b641f87b8a46..501b41987867 100644 --- a/src/material-experimental/mdc-chips/chip-grid.ts +++ b/src/material-experimental/mdc-chips/chip-grid.ts @@ -156,7 +156,7 @@ export class MatChipGrid override get disabled(): boolean { return this.ngControl ? !!this.ngControl.disabled : this._disabled; } - override set disabled(value: boolean) { + override set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._syncChipsState(); } @@ -189,7 +189,6 @@ export class MatChipGrid * @docs-private */ @Input() - @Input() get placeholder(): string { return this._chipInput ? this._chipInput.placeholder : this._placeholder; } @@ -212,7 +211,7 @@ export class MatChipGrid get required(): boolean { return this._required ?? this.ngControl?.control?.hasValidator(Validators.required) ?? false; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); this.stateChanges.next(); } @@ -554,9 +553,4 @@ export class MatChipGrid private _focusInput() { this._chipInput.focus(); } - - // Even though this member is inherited, we explicitly need to set it here as the `disabled` - // input is overwritten in this class too. This is needed for the lint rule. - static override ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_required: BooleanInput; } diff --git a/src/material-experimental/mdc-chips/chip-icons.ts b/src/material-experimental/mdc-chips/chip-icons.ts index 559bd0759fb5..3a21ca09bc3e 100644 --- a/src/material-experimental/mdc-chips/chip-icons.ts +++ b/src/material-experimental/mdc-chips/chip-icons.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {BooleanInput, NumberInput} from '@angular/cdk/coercion'; import {ChangeDetectorRef, Directive, ElementRef, InjectionToken, OnDestroy} from '@angular/core'; import { CanDisable, @@ -197,7 +196,4 @@ export class MatChipRemove extends _MatChipRemoveMixinBase implements CanDisable override focus() { this._elementRef.nativeElement.focus(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } diff --git a/src/material-experimental/mdc-chips/chip-input.ts b/src/material-experimental/mdc-chips/chip-input.ts index 4d921d5e208f..128c77f58c06 100644 --- a/src/material-experimental/mdc-chips/chip-input.ts +++ b/src/material-experimental/mdc-chips/chip-input.ts @@ -96,7 +96,7 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha get addOnBlur(): boolean { return this._addOnBlur; } - set addOnBlur(value: boolean) { + set addOnBlur(value: BooleanInput) { this._addOnBlur = coerceBooleanProperty(value); } _addOnBlur: boolean = false; @@ -125,7 +125,7 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha get disabled(): boolean { return this._disabled || (this._chipGrid && this._chipGrid.disabled); } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled: boolean = false; @@ -255,7 +255,4 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha private _isSeparatorKey(event: KeyboardEvent) { return !hasModifierKey(event) && new Set(this.separatorKeyCodes).has(event.keyCode); } - - static ngAcceptInputType_addOnBlur: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material-experimental/mdc-chips/chip-listbox.ts b/src/material-experimental/mdc-chips/chip-listbox.ts index 68a57270a225..9b9dad57dff1 100644 --- a/src/material-experimental/mdc-chips/chip-listbox.ts +++ b/src/material-experimental/mdc-chips/chip-listbox.ts @@ -118,7 +118,7 @@ export class MatChipListbox extends MatChipSet implements AfterContentInit, Cont get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { this._multiple = coerceBooleanProperty(value); this._updateMdcSelectionClasses(); this._syncListboxProperties(); @@ -144,7 +144,7 @@ export class MatChipListbox extends MatChipSet implements AfterContentInit, Cont get selectable(): boolean { return this._selectable; } - set selectable(value: boolean) { + set selectable(value: BooleanInput) { this._selectable = coerceBooleanProperty(value); this._updateMdcSelectionClasses(); this._syncListboxProperties(); @@ -171,7 +171,7 @@ export class MatChipListbox extends MatChipSet implements AfterContentInit, Cont get required(): boolean { return this._required; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } protected _required: boolean = false; @@ -560,8 +560,4 @@ export class MatChipListbox extends MatChipSet implements AfterContentInit, Cont this._lastDestroyedChipIndex = null; } - - static ngAcceptInputType_multiple: BooleanInput; - static ngAcceptInputType_selectable: BooleanInput; - static ngAcceptInputType_required: BooleanInput; } diff --git a/src/material-experimental/mdc-chips/chip-option.ts b/src/material-experimental/mdc-chips/chip-option.ts index 551619e2fc2a..3b9362ce17ac 100644 --- a/src/material-experimental/mdc-chips/chip-option.ts +++ b/src/material-experimental/mdc-chips/chip-option.ts @@ -83,7 +83,7 @@ export class MatChipOption extends MatChip implements AfterContentInit { get selectable(): boolean { return this._selectable && this.chipListSelectable; } - set selectable(value: boolean) { + set selectable(value: BooleanInput) { this._selectable = coerceBooleanProperty(value); } protected _selectable: boolean = true; @@ -93,7 +93,7 @@ export class MatChipOption extends MatChip implements AfterContentInit { get selected(): boolean { return this._chipFoundation.isSelected(); } - set selected(value: boolean) { + set selected(value: BooleanInput) { if (!this.selectable) { return; } @@ -232,7 +232,4 @@ export class MatChipOption extends MatChip implements AfterContentInit { this._handleInteraction(event); } } - - static ngAcceptInputType_selectable: BooleanInput; - static ngAcceptInputType_selected: BooleanInput; } diff --git a/src/material-experimental/mdc-chips/chip-row.ts b/src/material-experimental/mdc-chips/chip-row.ts index 768553eb2739..b811863c02b4 100644 --- a/src/material-experimental/mdc-chips/chip-row.ts +++ b/src/material-experimental/mdc-chips/chip-row.ts @@ -7,7 +7,6 @@ */ import {Directionality} from '@angular/cdk/bidi'; -import {BooleanInput} from '@angular/cdk/coercion'; import {BACKSPACE, DELETE} from '@angular/cdk/keycodes'; import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations'; import { @@ -255,6 +254,4 @@ export class MatChipRow private _getEditInput(): MatChipEditInput { return this.contentEditInput || this.defaultEditInput!; } - - static ngAcceptInputType_editable: BooleanInput; } diff --git a/src/material-experimental/mdc-chips/chip-set.ts b/src/material-experimental/mdc-chips/chip-set.ts index 20a6d4606015..ddbb16bada01 100644 --- a/src/material-experimental/mdc-chips/chip-set.ts +++ b/src/material-experimental/mdc-chips/chip-set.ts @@ -7,7 +7,7 @@ */ import {Directionality} from '@angular/cdk/bidi'; -import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion'; +import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import { AfterContentInit, AfterViewInit, @@ -123,7 +123,7 @@ export class MatChipSet get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._syncChipsState(); } @@ -342,7 +342,4 @@ export class MatChipSet return false; } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } diff --git a/src/material-experimental/mdc-chips/chip.ts b/src/material-experimental/mdc-chips/chip.ts index 9016c07d2cc4..ecac78189c33 100644 --- a/src/material-experimental/mdc-chips/chip.ts +++ b/src/material-experimental/mdc-chips/chip.ts @@ -7,7 +7,7 @@ */ import {Directionality} from '@angular/cdk/bidi'; -import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion'; +import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations'; import { AfterContentInit, @@ -159,10 +159,10 @@ export class MatChip get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); if (this.removeIcon) { - this.removeIcon.disabled = value; + this.removeIcon.disabled = this._disabled; } } protected _disabled: boolean = false; @@ -186,7 +186,7 @@ export class MatChip get removable(): boolean { return this._removable; } - set removable(value: boolean) { + set removable(value: BooleanInput) { this._removable = coerceBooleanProperty(value); } protected _removable: boolean = true; @@ -198,7 +198,7 @@ export class MatChip get highlighted(): boolean { return this._highlighted; } - set highlighted(value: boolean) { + set highlighted(value: BooleanInput) { this._highlighted = coerceBooleanProperty(value); } protected _highlighted: boolean = false; @@ -449,10 +449,4 @@ export class MatChip /** Overridden by MatChipRow. */ protected _onEditFinish() {} - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_removable: BooleanInput; - static ngAcceptInputType_highlighted: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } diff --git a/src/material-experimental/mdc-form-field/form-field.ts b/src/material-experimental/mdc-form-field/form-field.ts index 500bdc1baf49..2efd38383c73 100644 --- a/src/material-experimental/mdc-form-field/form-field.ts +++ b/src/material-experimental/mdc-form-field/form-field.ts @@ -162,7 +162,7 @@ export class MatFormField get hideRequiredMarker(): boolean { return this._hideRequiredMarker; } - set hideRequiredMarker(value: boolean) { + set hideRequiredMarker(value: BooleanInput) { this._hideRequiredMarker = coerceBooleanProperty(value); } private _hideRequiredMarker: boolean; @@ -745,6 +745,4 @@ export class MatFormField // shadow DOM, however browser that support shadow DOM should support `getRootNode` as well. return document.documentElement!.contains(element); } - - static ngAcceptInputType_hideRequiredMarker: BooleanInput; } diff --git a/src/material-experimental/mdc-list/list-base.ts b/src/material-experimental/mdc-list/list-base.ts index 314f028c2cb1..fb9547ac74b6 100644 --- a/src/material-experimental/mdc-list/list-base.ts +++ b/src/material-experimental/mdc-list/list-base.ts @@ -80,7 +80,7 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri get disabled(): boolean { return this._disabled || (this._listBase && this._listBase.disabled); } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; @@ -191,9 +191,6 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri ); }); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } @Directive({ @@ -211,7 +208,7 @@ export abstract class MatListBase { get disableRipple(): boolean { return this._disableRipple; } - set disableRipple(value: boolean) { + set disableRipple(value: BooleanInput) { this._disableRipple = coerceBooleanProperty(value); } private _disableRipple: boolean = false; @@ -221,11 +218,8 @@ export abstract class MatListBase { get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } diff --git a/src/material-experimental/mdc-list/list-option.ts b/src/material-experimental/mdc-list/list-option.ts index 11e8279c344f..52eef6d07eb8 100644 --- a/src/material-experimental/mdc-list/list-option.ts +++ b/src/material-experimental/mdc-list/list-option.ts @@ -146,7 +146,7 @@ export class MatListOption extends MatListItemBase implements ListOption, OnInit get selected(): boolean { return this._selectionList.selectedOptions.isSelected(this); } - set selected(value: boolean) { + set selected(value: BooleanInput) { const isSelected = coerceBooleanProperty(value); if (isSelected !== this._selected) { @@ -281,6 +281,4 @@ export class MatListOption extends MatListItemBase implements ListOption, OnInit _markForCheck() { this._changeDetectorRef.markForCheck(); } - - static ngAcceptInputType_selected: BooleanInput; } diff --git a/src/material-experimental/mdc-list/selection-list.ts b/src/material-experimental/mdc-list/selection-list.ts index fb10570f6f01..01af62d55921 100644 --- a/src/material-experimental/mdc-list/selection-list.ts +++ b/src/material-experimental/mdc-list/selection-list.ts @@ -103,7 +103,7 @@ export class MatSelectionList get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._multiple) { @@ -357,8 +357,6 @@ export class MatSelectionList get options(): QueryList { return this._items; } - - static ngAcceptInputType_multiple: BooleanInput; } // TODO: replace with class using inheritance once material-components-web/pull/6256 is available. diff --git a/src/material-experimental/mdc-progress-spinner/progress-spinner.ts b/src/material-experimental/mdc-progress-spinner/progress-spinner.ts index 98e98cbc0742..5f78bfb5349a 100644 --- a/src/material-experimental/mdc-progress-spinner/progress-spinner.ts +++ b/src/material-experimental/mdc-progress-spinner/progress-spinner.ts @@ -160,7 +160,7 @@ export class MatProgressSpinner return this.mode === 'determinate' ? this._value : 0; } - set value(v: number) { + set value(v: NumberInput) { this._value = Math.max(0, Math.min(100, coerceNumberProperty(v))); this._syncFoundation(); } @@ -173,7 +173,7 @@ export class MatProgressSpinner return this._diameter; } - set diameter(size: number) { + set diameter(size: NumberInput) { this._diameter = coerceNumberProperty(size); this._syncFoundation(); } @@ -186,7 +186,7 @@ export class MatProgressSpinner return this._strokeWidth ?? this.diameter / 10; } - set strokeWidth(value: number) { + set strokeWidth(value: NumberInput) { this._strokeWidth = coerceNumberProperty(value); } @@ -241,10 +241,6 @@ export class MatProgressSpinner foundation.setDeterminate(mode === 'determinate'); } } - - static ngAcceptInputType_diameter: NumberInput; - static ngAcceptInputType_strokeWidth: NumberInput; - static ngAcceptInputType_value: NumberInput; } /** diff --git a/src/material-experimental/mdc-slide-toggle/slide-toggle.ts b/src/material-experimental/mdc-slide-toggle/slide-toggle.ts index 058238c8a43a..24a6c632b1ae 100644 --- a/src/material-experimental/mdc-slide-toggle/slide-toggle.ts +++ b/src/material-experimental/mdc-slide-toggle/slide-toggle.ts @@ -123,7 +123,7 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe get tabIndex(): number { return this._tabIndex; } - set tabIndex(value: number) { + set tabIndex(value: NumberInput) { this._tabIndex = coerceNumberProperty(value); } private _tabIndex: number; @@ -145,7 +145,7 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe get required(): boolean { return this._required; } - set required(value) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } @@ -154,7 +154,7 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe get checked(): boolean { return this._checked; } - set checked(value) { + set checked(value: BooleanInput) { this._checked = coerceBooleanProperty(value); if (this._foundation) { @@ -167,7 +167,7 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe get disableRipple(): boolean { return this._disableRipple; } - set disableRipple(disableRipple: boolean) { + set disableRipple(disableRipple: BooleanInput) { this._disableRipple = coerceBooleanProperty(disableRipple); } private _disableRipple = false; @@ -177,7 +177,7 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe get disabled(): boolean { return this._disabled; } - set disabled(disabled) { + set disabled(disabled: BooleanInput) { this._disabled = coerceBooleanProperty(disabled); if (this._foundation) { @@ -297,10 +297,4 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe // `aria-labelledby`, because the button gets flagged as not having a label by tools like axe. return this.ariaLabel ? null : this._labelId; } - - static ngAcceptInputType_tabIndex: NumberInput; - static ngAcceptInputType_required: BooleanInput; - static ngAcceptInputType_checked: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material-experimental/mdc-slider/slider.ts b/src/material-experimental/mdc-slider/slider.ts index 28a1c438e4f8..d6f84a323425 100644 --- a/src/material-experimental/mdc-slider/slider.ts +++ b/src/material-experimental/mdc-slider/slider.ts @@ -305,7 +305,7 @@ export class MatSliderThumb implements AfterViewInit, ControlValueAccessor, OnIn get value(): number { return coerceNumberProperty(this._hostElement.getAttribute('value')); } - set value(v: number) { + set value(v: NumberInput) { const value = coerceNumberProperty(v); // If the foundation has already been initialized, we need to @@ -524,8 +524,6 @@ export class MatSliderThumb implements AfterViewInit, ControlValueAccessor, OnIn private _initializeAriaValueText(): void { this._hostElement.setAttribute('aria-valuetext', this._slider.displayWith(this.value)); } - - static ngAcceptInputType_value: NumberInput; } // Boilerplate for applying mixins to MatSlider. @@ -578,7 +576,7 @@ export class MatSlider get disabled(): boolean { return this._disabled; } - set disabled(v: boolean) { + set disabled(v: BooleanInput) { this._setDisabled(coerceBooleanProperty(v)); this._updateInputsDisabledState(); } @@ -589,7 +587,7 @@ export class MatSlider get discrete(): boolean { return this._discrete; } - set discrete(v: boolean) { + set discrete(v: BooleanInput) { this._discrete = coerceBooleanProperty(v); } private _discrete: boolean = false; @@ -599,7 +597,7 @@ export class MatSlider get showTickMarks(): boolean { return this._showTickMarks; } - set showTickMarks(v: boolean) { + set showTickMarks(v: BooleanInput) { this._showTickMarks = coerceBooleanProperty(v); } private _showTickMarks: boolean = false; @@ -609,7 +607,7 @@ export class MatSlider get min(): number { return this._min; } - set min(v: number) { + set min(v: NumberInput) { this._min = coerceNumberProperty(v, this._min); this._reinitialize(); } @@ -620,7 +618,7 @@ export class MatSlider get max(): number { return this._max; } - set max(v: number) { + set max(v: NumberInput) { this._max = coerceNumberProperty(v, this._max); this._reinitialize(); } @@ -631,7 +629,7 @@ export class MatSlider get step(): number { return this._step; } - set step(v: number) { + set step(v: NumberInput) { this._step = coerceNumberProperty(v, this._step); this._reinitialize(); } @@ -900,14 +898,6 @@ export class MatSlider _isRippleDisabled(): boolean { return this.disabled || this.disableRipple || !!this._globalRippleOptions?.disabled; } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_discrete: BooleanInput; - static ngAcceptInputType_showTickMarks: BooleanInput; - static ngAcceptInputType_min: NumberInput; - static ngAcceptInputType_max: NumberInput; - static ngAcceptInputType_step: NumberInput; - static ngAcceptInputType_disableRipple: BooleanInput; } /** The MDCSliderAdapter implementation. */ diff --git a/src/material-experimental/mdc-tabs/tab-group.ts b/src/material-experimental/mdc-tabs/tab-group.ts index 6b33748921b8..e268f713057f 100644 --- a/src/material-experimental/mdc-tabs/tab-group.ts +++ b/src/material-experimental/mdc-tabs/tab-group.ts @@ -65,7 +65,7 @@ export class MatTabGroup extends _MatTabGroupBase { get fitInkBarToContent(): boolean { return this._fitInkBarToContent; } - set fitInkBarToContent(v: boolean) { + set fitInkBarToContent(v: BooleanInput) { this._fitInkBarToContent = coerceBooleanProperty(v); this._changeDetectorRef.markForCheck(); } @@ -83,6 +83,4 @@ export class MatTabGroup extends _MatTabGroupBase { ? defaultConfig.fitInkBarToContent : false; } - - static ngAcceptInputType_fitInkBarToContent: BooleanInput; } diff --git a/src/material-experimental/mdc-tabs/tab-header.ts b/src/material-experimental/mdc-tabs/tab-header.ts index 9d080ac7a599..e733577679fc 100644 --- a/src/material-experimental/mdc-tabs/tab-header.ts +++ b/src/material-experimental/mdc-tabs/tab-header.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {BooleanInput} from '@angular/cdk/coercion'; import { ChangeDetectionStrategy, Component, @@ -75,6 +74,4 @@ export class MatTabHeader extends _MatTabHeaderBase implements AfterContentInit this._inkBar = new MatInkBar(this._items); super.ngAfterContentInit(); } - - static ngAcceptInputType_disableRipple: BooleanInput; } diff --git a/src/material-experimental/mdc-tabs/tab-label-wrapper.ts b/src/material-experimental/mdc-tabs/tab-label-wrapper.ts index ed99c6fb3592..9120da032d03 100644 --- a/src/material-experimental/mdc-tabs/tab-label-wrapper.ts +++ b/src/material-experimental/mdc-tabs/tab-label-wrapper.ts @@ -37,7 +37,7 @@ export class MatTabLabelWrapper get fitInkBarToContent(): boolean { return this._foundation.getFitToContent(); } - set fitInkBarToContent(v: boolean) { + set fitInkBarToContent(v: BooleanInput) { this._foundation.setFitToContent(coerceBooleanProperty(v)); } @@ -54,6 +54,4 @@ export class MatTabLabelWrapper ngOnDestroy() { this._foundation.destroy(); } - - static ngAcceptInputType_fitInkBarToContent: BooleanInput; } diff --git a/src/material-experimental/mdc-tabs/tab-nav-bar/tab-nav-bar.ts b/src/material-experimental/mdc-tabs/tab-nav-bar/tab-nav-bar.ts index c37f7c41a9a8..ca883653cf59 100644 --- a/src/material-experimental/mdc-tabs/tab-nav-bar/tab-nav-bar.ts +++ b/src/material-experimental/mdc-tabs/tab-nav-bar/tab-nav-bar.ts @@ -73,7 +73,7 @@ export class MatTabNav extends _MatTabNavBase implements AfterContentInit { get fitInkBarToContent(): boolean { return this._fitInkBarToContent.value; } - set fitInkBarToContent(v: boolean) { + set fitInkBarToContent(v: BooleanInput) { this._fitInkBarToContent.next(coerceBooleanProperty(v)); this._changeDetectorRef.markForCheck(); } @@ -112,9 +112,6 @@ export class MatTabNav extends _MatTabNavBase implements AfterContentInit { this._inkBar = new MatInkBar(this._items); super.ngAfterContentInit(); } - - static ngAcceptInputType_fitInkBarToContent: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } /** diff --git a/src/material/autocomplete/autocomplete-trigger.ts b/src/material/autocomplete/autocomplete-trigger.ts index 2495dbd1cae7..ccb6078b32cb 100644 --- a/src/material/autocomplete/autocomplete-trigger.ts +++ b/src/material/autocomplete/autocomplete-trigger.ts @@ -181,7 +181,7 @@ export abstract class _MatAutocompleteTriggerBase get autocompleteDisabled(): boolean { return this._autocompleteDisabled; } - set autocompleteDisabled(value: boolean) { + set autocompleteDisabled(value: BooleanInput) { this._autocompleteDisabled = coerceBooleanProperty(value); } @@ -768,8 +768,6 @@ export abstract class _MatAutocompleteTriggerBase } } } - - static ngAcceptInputType_autocompleteDisabled: BooleanInput; } @Directive({ diff --git a/src/material/autocomplete/autocomplete.ts b/src/material/autocomplete/autocomplete.ts index 43570ce0a1a2..ad025695f812 100644 --- a/src/material/autocomplete/autocomplete.ts +++ b/src/material/autocomplete/autocomplete.ts @@ -151,7 +151,7 @@ export abstract class _MatAutocompleteBase get autoActiveFirstOption(): boolean { return this._autoActiveFirstOption; } - set autoActiveFirstOption(value: boolean) { + set autoActiveFirstOption(value: BooleanInput) { this._autoActiveFirstOption = coerceBooleanProperty(value); } private _autoActiveFirstOption: boolean; @@ -280,9 +280,6 @@ export abstract class _MatAutocompleteBase classList[this._visibleClass] = this.showPanel; classList[this._hiddenClass] = !this.showPanel; } - - static ngAcceptInputType_autoActiveFirstOption: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } @Component({ diff --git a/src/material/badge/badge.ts b/src/material/badge/badge.ts index 3531a8c1336a..f13b44753530 100644 --- a/src/material/badge/badge.ts +++ b/src/material/badge/badge.ts @@ -79,7 +79,7 @@ export class MatBadge extends _MatBadgeBase implements OnInit, OnDestroy, CanDis get overlap(): boolean { return this._overlap; } - set overlap(val: boolean) { + set overlap(val: BooleanInput) { this._overlap = coerceBooleanProperty(val); } private _overlap: boolean = true; @@ -118,7 +118,7 @@ export class MatBadge extends _MatBadgeBase implements OnInit, OnDestroy, CanDis get hidden(): boolean { return this._hidden; } - set hidden(val: boolean) { + set hidden(val: BooleanInput) { this._hidden = coerceBooleanProperty(val); } private _hidden: boolean; @@ -272,8 +272,4 @@ export class MatBadge extends _MatBadgeBase implements OnInit, OnDestroy, CanDis } } } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_hidden: BooleanInput; - static ngAcceptInputType_overlap: BooleanInput; } diff --git a/src/material/button-toggle/button-toggle.ts b/src/material/button-toggle/button-toggle.ts index d6bcd7e7c1e8..6ece57bc974c 100644 --- a/src/material/button-toggle/button-toggle.ts +++ b/src/material/button-toggle/button-toggle.ts @@ -170,7 +170,7 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After get vertical(): boolean { return this._vertical; } - set vertical(value: boolean) { + set vertical(value: BooleanInput) { this._vertical = coerceBooleanProperty(value); } @@ -208,7 +208,7 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { this._multiple = coerceBooleanProperty(value); } @@ -217,7 +217,7 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); if (this._buttonToggles) { @@ -387,10 +387,6 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After // it is used by Angular to sync up the two-way data binding. this.valueChange.emit(this.value); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_multiple: BooleanInput; - static ngAcceptInputType_vertical: BooleanInput; } // Boilerplate for applying mixins to the MatButtonToggle class. @@ -476,7 +472,7 @@ export class MatButtonToggle get checked(): boolean { return this.buttonToggleGroup ? this.buttonToggleGroup._isSelected(this) : this._checked; } - set checked(value: boolean) { + set checked(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._checked) { @@ -495,7 +491,7 @@ export class MatButtonToggle get disabled(): boolean { return this._disabled || (this.buttonToggleGroup && this.buttonToggleGroup.disabled); } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled: boolean = false; @@ -591,10 +587,4 @@ export class MatButtonToggle // Use `markForCheck` to explicit update button toggle's status. this._changeDetectorRef.markForCheck(); } - - static ngAcceptInputType_checked: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_vertical: BooleanInput; - static ngAcceptInputType_multiple: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } diff --git a/src/material/button/button.ts b/src/material/button/button.ts index cef104c30d04..96b24e98f7e7 100644 --- a/src/material/button/button.ts +++ b/src/material/button/button.ts @@ -7,7 +7,6 @@ */ import {FocusMonitor, FocusableOption, FocusOrigin} from '@angular/cdk/a11y'; -import {BooleanInput} from '@angular/cdk/coercion'; import { ChangeDetectionStrategy, Component, @@ -149,9 +148,6 @@ export class MatButton _hasHostAttributes(...attributes: string[]) { return attributes.some(attribute => this._getHostElement().hasAttribute(attribute)); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } /** diff --git a/src/material/checkbox/checkbox.ts b/src/material/checkbox/checkbox.ts index 951a12e6e9d4..ee0fcc07e20d 100644 --- a/src/material/checkbox/checkbox.ts +++ b/src/material/checkbox/checkbox.ts @@ -7,7 +7,7 @@ */ import {FocusableOption, FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; -import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion'; +import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import { AfterViewChecked, Attribute, @@ -170,7 +170,7 @@ export class MatCheckbox get required(): boolean { return this._required; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } private _required: boolean; @@ -271,10 +271,10 @@ export class MatCheckbox * mixinDisabled, but the mixin is still required because mixinTabIndex requires it. */ @Input() - override get disabled() { + override get disabled(): boolean { return this._disabled; } - override set disabled(value: any) { + override set disabled(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this.disabled) { @@ -294,7 +294,7 @@ export class MatCheckbox get indeterminate(): boolean { return this._indeterminate; } - set indeterminate(value: boolean) { + set indeterminate(value: BooleanInput) { const changed = value != this._indeterminate; this._indeterminate = coerceBooleanProperty(value); @@ -529,10 +529,4 @@ export class MatCheckbox nativeCheckbox.nativeElement.indeterminate = value; } } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_required: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_indeterminate: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } diff --git a/src/material/chips/chip-input.ts b/src/material/chips/chip-input.ts index 4f17bac9f54a..94f7eacad7e1 100644 --- a/src/material/chips/chip-input.ts +++ b/src/material/chips/chip-input.ts @@ -90,7 +90,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, A get addOnBlur(): boolean { return this._addOnBlur; } - set addOnBlur(value: boolean) { + set addOnBlur(value: BooleanInput) { this._addOnBlur = coerceBooleanProperty(value); } _addOnBlur: boolean = false; @@ -118,7 +118,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, A get disabled(): boolean { return this._disabled || (this._chipList && this._chipList.disabled); } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled: boolean = false; @@ -241,7 +241,4 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, A private _isSeparatorKey(event: KeyboardEvent) { return !hasModifierKey(event) && new Set(this.separatorKeyCodes).has(event.keyCode); } - - static ngAcceptInputType_addOnBlur: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material/chips/chip-list.ts b/src/material/chips/chip-list.ts index abb45b21f5b9..11b8741ee05b 100644 --- a/src/material/chips/chip-list.ts +++ b/src/material/chips/chip-list.ts @@ -185,7 +185,7 @@ export class MatChipList get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { this._multiple = coerceBooleanProperty(value); this._syncChipsState(); } @@ -239,7 +239,7 @@ export class MatChipList get required(): boolean { return this._required ?? this.ngControl?.control?.hasValidator(Validators.required) ?? false; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); this.stateChanges.next(); } @@ -288,7 +288,7 @@ export class MatChipList get disabled(): boolean { return this.ngControl ? !!this.ngControl.disabled : this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._syncChipsState(); } @@ -305,7 +305,7 @@ export class MatChipList get selectable(): boolean { return this._selectable; } - set selectable(value: boolean) { + set selectable(value: BooleanInput) { this._selectable = coerceBooleanProperty(value); if (this.chips) { @@ -821,9 +821,4 @@ export class MatChipList }); } } - - static ngAcceptInputType_multiple: BooleanInput; - static ngAcceptInputType_required: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_selectable: BooleanInput; } diff --git a/src/material/chips/chip.ts b/src/material/chips/chip.ts index ea002aaaa6a1..d0a9114af50e 100644 --- a/src/material/chips/chip.ts +++ b/src/material/chips/chip.ts @@ -7,7 +7,7 @@ */ import {FocusableOption} from '@angular/cdk/a11y'; -import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion'; +import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import {BACKSPACE, DELETE, SPACE} from '@angular/cdk/keycodes'; import {Platform} from '@angular/cdk/platform'; import {DOCUMENT} from '@angular/common'; @@ -212,7 +212,7 @@ export class MatChip get selected(): boolean { return this._selected; } - set selected(value: boolean) { + set selected(value: BooleanInput) { const coercedValue = coerceBooleanProperty(value); if (coercedValue !== this._selected) { @@ -242,7 +242,7 @@ export class MatChip get selectable(): boolean { return this._selectable && this.chipListSelectable; } - set selectable(value: boolean) { + set selectable(value: BooleanInput) { this._selectable = coerceBooleanProperty(value); } protected _selectable: boolean = true; @@ -252,7 +252,7 @@ export class MatChip get disabled(): boolean { return this._chipListDisabled || this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } protected _disabled: boolean = false; @@ -264,7 +264,7 @@ export class MatChip get removable(): boolean { return this._removable; } - set removable(value: boolean) { + set removable(value: BooleanInput) { this._removable = coerceBooleanProperty(value); } protected _removable: boolean = true; @@ -455,13 +455,6 @@ export class MatChip selected: this._selected, }); } - - static ngAcceptInputType_selected: BooleanInput; - static ngAcceptInputType_selectable: BooleanInput; - static ngAcceptInputType_removable: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } /** diff --git a/src/material/core/common-behaviors/disable-ripple.ts b/src/material/core/common-behaviors/disable-ripple.ts index a9994e86440e..8b55bc6376cf 100644 --- a/src/material/core/common-behaviors/disable-ripple.ts +++ b/src/material/core/common-behaviors/disable-ripple.ts @@ -26,7 +26,7 @@ export function mixinDisableRipple>(base: T): CanDisab private _disableRipple: boolean = false; /** Whether the ripple effect is disabled or not. */ - get disableRipple() { + get disableRipple(): boolean { return this._disableRipple; } set disableRipple(value: any) { diff --git a/src/material/core/common-behaviors/disabled.ts b/src/material/core/common-behaviors/disabled.ts index 23d100ceb0d8..59eaf071f41c 100644 --- a/src/material/core/common-behaviors/disabled.ts +++ b/src/material/core/common-behaviors/disabled.ts @@ -23,7 +23,7 @@ export function mixinDisabled>(base: T): CanDisableCto return class extends base { private _disabled: boolean = false; - get disabled() { + get disabled(): boolean { return this._disabled; } set disabled(value: any) { diff --git a/src/material/core/option/optgroup.ts b/src/material/core/option/optgroup.ts index 27cf1d8498bd..08dff3b9bbe2 100644 --- a/src/material/core/option/optgroup.ts +++ b/src/material/core/option/optgroup.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {BooleanInput} from '@angular/cdk/coercion'; import { ChangeDetectionStrategy, Component, @@ -62,8 +61,6 @@ export class _MatOptgroupBase extends _MatOptgroupMixinBase implements CanDisabl super(); this._inert = parent?.inertGroups ?? false; } - - static ngAcceptInputType_disabled: BooleanInput; } /** diff --git a/src/material/core/option/option.ts b/src/material/core/option/option.ts index 3b58ceb39146..cdab4794355d 100644 --- a/src/material/core/option/option.ts +++ b/src/material/core/option/option.ts @@ -70,16 +70,16 @@ export class _MatOptionBase implements FocusableOption, AfterViewChecked, OnDest /** Whether the option is disabled. */ @Input() - get disabled() { + get disabled(): boolean { return (this.group && this.group.disabled) || this._disabled; } - set disabled(value: any) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } /** Whether ripples for the option are disabled. */ - get disableRipple() { - return this._parent && this._parent.disableRipple; + get disableRipple(): boolean { + return !!(this._parent && this._parent.disableRipple); } /** Event emitted when the option is selected or deselected. */ @@ -239,8 +239,6 @@ export class _MatOptionBase implements FocusableOption, AfterViewChecked, OnDest private _emitSelectionChangeEvent(isUserInput = false): void { this.onSelectionChange.emit(new MatOptionSelectionChange(this, isUserInput)); } - - static ngAcceptInputType_disabled: BooleanInput; } /** diff --git a/src/material/datepicker/date-range-input.ts b/src/material/datepicker/date-range-input.ts index b9f458b16d8e..9af6b2d299b2 100644 --- a/src/material/datepicker/date-range-input.ts +++ b/src/material/datepicker/date-range-input.ts @@ -132,7 +132,7 @@ export class MatDateRangeInput get required(): boolean { return !!this._required; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } private _required: boolean; @@ -196,7 +196,7 @@ export class MatDateRangeInput ? this._startInput.disabled && this._endInput.disabled : this._groupDisabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._groupDisabled) { @@ -413,7 +413,4 @@ export class MatDateRangeInput this._endInput._registerModel(model); } } - - static ngAcceptInputType_required: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material/datepicker/datepicker-base.ts b/src/material/datepicker/datepicker-base.ts index b2b855cfedc7..2982e852c15e 100644 --- a/src/material/datepicker/datepicker-base.ts +++ b/src/material/datepicker/datepicker-base.ts @@ -327,7 +327,7 @@ export abstract class MatDatepickerBase< get touchUi(): boolean { return this._touchUi; } - set touchUi(value: boolean) { + set touchUi(value: BooleanInput) { this._touchUi = coerceBooleanProperty(value); } private _touchUi = false; @@ -339,7 +339,7 @@ export abstract class MatDatepickerBase< ? this.datepickerInput.disabled : !!this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._disabled) { @@ -366,7 +366,7 @@ export abstract class MatDatepickerBase< get restoreFocus(): boolean { return this._restoreFocus; } - set restoreFocus(value: boolean) { + set restoreFocus(value: BooleanInput) { this._restoreFocus = coerceBooleanProperty(value); } private _restoreFocus = true; @@ -417,7 +417,7 @@ export abstract class MatDatepickerBase< get opened(): boolean { return this._opened; } - set opened(value: boolean) { + set opened(value: BooleanInput) { coerceBooleanProperty(value) ? this.open() : this.close(); } private _opened = false; @@ -751,9 +751,4 @@ export abstract class MatDatepickerBase< ), ); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_opened: BooleanInput; - static ngAcceptInputType_touchUi: BooleanInput; - static ngAcceptInputType_restoreFocus: BooleanInput; } diff --git a/src/material/datepicker/datepicker-input-base.ts b/src/material/datepicker/datepicker-input-base.ts index 8dcf56196c12..e2dbe967f035 100644 --- a/src/material/datepicker/datepicker-input-base.ts +++ b/src/material/datepicker/datepicker-input-base.ts @@ -72,7 +72,7 @@ export abstract class MatDatepickerInputBase | undefined; @@ -82,7 +82,7 @@ export abstract class MatDatepickerInputBase` that - // may accept different types. - static ngAcceptInputType_value: any; - static ngAcceptInputType_disabled: BooleanInput; } /** diff --git a/src/material/datepicker/datepicker-toggle.ts b/src/material/datepicker/datepicker-toggle.ts index 6a792400fa71..3f6144f3a5c6 100644 --- a/src/material/datepicker/datepicker-toggle.ts +++ b/src/material/datepicker/datepicker-toggle.ts @@ -75,7 +75,7 @@ export class MatDatepickerToggle implements AfterContentInit, OnChanges, OnDe return !!this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled: boolean; @@ -137,6 +137,4 @@ export class MatDatepickerToggle implements AfterContentInit, OnChanges, OnDe datepickerToggled, ).subscribe(() => this._changeDetectorRef.markForCheck()); } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material/divider/divider.ts b/src/material/divider/divider.ts index e5698829a62d..c791d16ea2ec 100644 --- a/src/material/divider/divider.ts +++ b/src/material/divider/divider.ts @@ -30,7 +30,7 @@ export class MatDivider { get vertical(): boolean { return this._vertical; } - set vertical(value: boolean) { + set vertical(value: BooleanInput) { this._vertical = coerceBooleanProperty(value); } private _vertical: boolean = false; @@ -40,11 +40,8 @@ export class MatDivider { get inset(): boolean { return this._inset; } - set inset(value: boolean) { + set inset(value: BooleanInput) { this._inset = coerceBooleanProperty(value); } private _inset: boolean = false; - - static ngAcceptInputType_vertical: BooleanInput; - static ngAcceptInputType_inset: BooleanInput; } diff --git a/src/material/expansion/accordion.ts b/src/material/expansion/accordion.ts index cdd8664d41d6..9eb9b0a89a2a 100644 --- a/src/material/expansion/accordion.ts +++ b/src/material/expansion/accordion.ts @@ -64,7 +64,7 @@ export class MatAccordion get hideToggle(): boolean { return this._hideToggle; } - set hideToggle(show: boolean) { + set hideToggle(show: BooleanInput) { this._hideToggle = coerceBooleanProperty(show); } private _hideToggle: boolean = false; @@ -106,6 +106,4 @@ export class MatAccordion super.ngOnDestroy(); this._ownHeaders.destroy(); } - - static ngAcceptInputType_hideToggle: BooleanInput; } diff --git a/src/material/expansion/expansion-panel-header.ts b/src/material/expansion/expansion-panel-header.ts index a6801fcf9d29..93641bf2627e 100644 --- a/src/material/expansion/expansion-panel-header.ts +++ b/src/material/expansion/expansion-panel-header.ts @@ -25,7 +25,6 @@ import { } from '@angular/core'; import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations'; import {HasTabIndex, mixinTabIndex} from '@angular/material/core'; -import {NumberInput} from '@angular/cdk/coercion'; import {EMPTY, merge, Subscription} from 'rxjs'; import {filter} from 'rxjs/operators'; import {MatAccordionTogglePosition} from './accordion-base'; @@ -226,8 +225,6 @@ export class MatExpansionPanelHeader this._parentChangeSubscription.unsubscribe(); this._focusMonitor.stopMonitoring(this._element); } - - static ngAcceptInputType_tabIndex: NumberInput; } /** diff --git a/src/material/expansion/expansion-panel.ts b/src/material/expansion/expansion-panel.ts index 91cf1a8f3ae8..8b7b07e406d9 100644 --- a/src/material/expansion/expansion-panel.ts +++ b/src/material/expansion/expansion-panel.ts @@ -108,7 +108,7 @@ export class MatExpansionPanel get hideToggle(): boolean { return this._hideToggle || (this.accordion && this.accordion.hideToggle); } - set hideToggle(value: boolean) { + set hideToggle(value: BooleanInput) { this._hideToggle = coerceBooleanProperty(value); } @@ -249,8 +249,6 @@ export class MatExpansionPanel return false; } - - static ngAcceptInputType_hideToggle: BooleanInput; } /** diff --git a/src/material/form-field/form-field.ts b/src/material/form-field/form-field.ts index 0cba8d23a34d..21975e33ea37 100644 --- a/src/material/form-field/form-field.ts +++ b/src/material/form-field/form-field.ts @@ -179,7 +179,7 @@ export class MatFormField get hideRequiredMarker(): boolean { return this._hideRequiredMarker; } - set hideRequiredMarker(value: boolean) { + set hideRequiredMarker(value: BooleanInput) { this._hideRequiredMarker = coerceBooleanProperty(value); } private _hideRequiredMarker: boolean; @@ -635,6 +635,4 @@ export class MatFormField // shadow DOM, however browser that support shadow DOM should support `getRootNode` as well. return document.documentElement!.contains(element); } - - static ngAcceptInputType_hideRequiredMarker: BooleanInput; } diff --git a/src/material/grid-list/grid-list.ts b/src/material/grid-list/grid-list.ts index a28b22e19b01..8b12daddf31a 100644 --- a/src/material/grid-list/grid-list.ts +++ b/src/material/grid-list/grid-list.ts @@ -91,7 +91,7 @@ export class MatGridList implements MatGridListBase, OnInit, AfterContentChecked get cols(): number { return this._cols; } - set cols(value: number) { + set cols(value: NumberInput) { this._cols = Math.max(1, Math.round(coerceNumberProperty(value))); } @@ -189,6 +189,4 @@ export class MatGridList implements MatGridListBase, OnInit, AfterContentChecked (this._element.nativeElement.style as any)[style[0]] = style[1]; } } - - static ngAcceptInputType_cols: NumberInput; } diff --git a/src/material/grid-list/grid-tile.ts b/src/material/grid-list/grid-tile.ts index 8b521b6d67fb..6d957250e735 100644 --- a/src/material/grid-list/grid-tile.ts +++ b/src/material/grid-list/grid-tile.ts @@ -52,7 +52,7 @@ export class MatGridTile { get rowspan(): number { return this._rowspan; } - set rowspan(value: number) { + set rowspan(value: NumberInput) { this._rowspan = Math.round(coerceNumberProperty(value)); } @@ -61,7 +61,7 @@ export class MatGridTile { get colspan(): number { return this._colspan; } - set colspan(value: number) { + set colspan(value: NumberInput) { this._colspan = Math.round(coerceNumberProperty(value)); } @@ -72,9 +72,6 @@ export class MatGridTile { _setStyle(property: string, value: any): void { (this._element.nativeElement.style as any)[property] = value; } - - static ngAcceptInputType_rowspan: NumberInput; - static ngAcceptInputType_colspan: NumberInput; } @Component({ diff --git a/src/material/icon/icon.ts b/src/material/icon/icon.ts index 24f0e34058cc..7fd9f00cdecc 100644 --- a/src/material/icon/icon.ts +++ b/src/material/icon/icon.ts @@ -143,7 +143,7 @@ export class MatIcon extends _MatIconBase implements OnInit, AfterViewChecked, C get inline(): boolean { return this._inline; } - set inline(inline: boolean) { + set inline(inline: BooleanInput) { this._inline = coerceBooleanProperty(inline); } private _inline: boolean = false; @@ -448,6 +448,4 @@ export class MatIcon extends _MatIconBase implements OnInit, AfterViewChecked, C ); } } - - static ngAcceptInputType_inline: BooleanInput; } diff --git a/src/material/input/input.ts b/src/material/input/input.ts index 473040a9ba6d..7c4abffd45a1 100644 --- a/src/material/input/input.ts +++ b/src/material/input/input.ts @@ -152,7 +152,7 @@ export class MatInput } return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); // Browsers may not fire the blur event if the input is disabled too quickly. @@ -191,7 +191,7 @@ export class MatInput get required(): boolean { return this._required ?? this.ngControl?.control?.hasValidator(Validators.required) ?? false; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } protected _required: boolean | undefined; @@ -231,7 +231,7 @@ export class MatInput get value(): string { return this._inputValueAccessor.value; } - set value(value: string) { + set value(value: any) { if (value !== this.value) { this._inputValueAccessor.value = value; this.stateChanges.next(); @@ -243,7 +243,7 @@ export class MatInput get readonly(): boolean { return this._readonly; } - set readonly(value: boolean) { + set readonly(value: BooleanInput) { this._readonly = coerceBooleanProperty(value); } private _readonly = false; @@ -501,12 +501,4 @@ export class MatInput const element = this._elementRef.nativeElement as HTMLSelectElement; return this._isNativeSelect && (element.multiple || element.size > 1); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_readonly: BooleanInput; - static ngAcceptInputType_required: BooleanInput; - - // Accept `any` to avoid conflicts with other directives on `` that may - // accept different types. - static ngAcceptInputType_value: any; } diff --git a/src/material/list/list.ts b/src/material/list/list.ts index 8365d2945376..4c54050a5405 100644 --- a/src/material/list/list.ts +++ b/src/material/list/list.ts @@ -86,9 +86,6 @@ export class MatNavList ngOnDestroy() { this._stateChanges.complete(); } - - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } @Component({ @@ -140,9 +137,6 @@ export class MatList ngOnDestroy() { this._stateChanges.complete(); } - - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } /** @@ -232,10 +226,10 @@ export class MatListItem /** Whether the option is disabled. */ @Input() - get disabled() { + get disabled(): boolean { return this._disabled || !!(this._list && this._list.disabled); } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; @@ -260,7 +254,4 @@ export class MatListItem _getHostElement(): HTMLElement { return this._element.nativeElement; } - - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material/list/selection-list.ts b/src/material/list/selection-list.ts index 6dd559c23fed..fa5e22aa078b 100644 --- a/src/material/list/selection-list.ts +++ b/src/material/list/selection-list.ts @@ -171,10 +171,10 @@ export class MatListOption /** Whether the option is disabled. */ @Input() - get disabled() { + get disabled(): boolean { return this._disabled || (this.selectionList && this.selectionList.disabled); } - set disabled(value: any) { + set disabled(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._disabled) { @@ -188,7 +188,7 @@ export class MatListOption get selected(): boolean { return this.selectionList.selectedOptions.isSelected(this); } - set selected(value: boolean) { + set selected(value: BooleanInput) { const isSelected = coerceBooleanProperty(value); if (isSelected !== this._selected) { @@ -328,10 +328,6 @@ export class MatListOption _markForCheck() { this._changeDetector.markForCheck(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_selected: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } /** @@ -393,7 +389,7 @@ export class MatSelectionList get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); // The `MatSelectionList` and `MatListOption` are using the `OnPush` change detection @@ -409,7 +405,7 @@ export class MatSelectionList get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._multiple) { @@ -765,8 +761,4 @@ export class MatSelectionList private _updateTabIndex(): void { this._tabIndex = this.options.length === 0 ? -1 : 0; } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_multiple: BooleanInput; } diff --git a/src/material/menu/menu-item.ts b/src/material/menu/menu-item.ts index b165c22b5830..63bb1ce25852 100644 --- a/src/material/menu/menu-item.ts +++ b/src/material/menu/menu-item.ts @@ -7,7 +7,6 @@ */ import {FocusableOption, FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; -import {BooleanInput} from '@angular/cdk/coercion'; import { ChangeDetectionStrategy, Component, @@ -176,7 +175,4 @@ export class MatMenuItem this._highlighted = isHighlighted; this._changeDetectorRef?.markForCheck(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } diff --git a/src/material/menu/menu.ts b/src/material/menu/menu.ts index 11f403d42166..c7718eddfa1d 100644 --- a/src/material/menu/menu.ts +++ b/src/material/menu/menu.ts @@ -198,7 +198,7 @@ export class _MatMenuBase get overlapTrigger(): boolean { return this._overlapTrigger; } - set overlapTrigger(value: boolean) { + set overlapTrigger(value: BooleanInput) { this._overlapTrigger = coerceBooleanProperty(value); } private _overlapTrigger: boolean = this._defaultOptions.overlapTrigger; @@ -208,7 +208,7 @@ export class _MatMenuBase get hasBackdrop(): boolean | undefined { return this._hasBackdrop; } - set hasBackdrop(value: boolean | undefined) { + set hasBackdrop(value: BooleanInput) { this._hasBackdrop = coerceBooleanProperty(value); } private _hasBackdrop: boolean | undefined = this._defaultOptions.hasBackdrop; @@ -495,9 +495,6 @@ export class _MatMenuBase this._directDescendantItems.notifyOnChanges(); }); } - - static ngAcceptInputType_overlapTrigger: BooleanInput; - static ngAcceptInputType_hasBackdrop: BooleanInput; } /** @docs-public MatMenu */ diff --git a/src/material/paginator/paginator.ts b/src/material/paginator/paginator.ts index da80f713d1dc..894fcbb6ee37 100644 --- a/src/material/paginator/paginator.ts +++ b/src/material/paginator/paginator.ts @@ -116,7 +116,7 @@ export abstract class _MatPaginatorBase< get pageIndex(): number { return this._pageIndex; } - set pageIndex(value: number) { + set pageIndex(value: NumberInput) { this._pageIndex = Math.max(coerceNumberProperty(value), 0); this._changeDetectorRef.markForCheck(); } @@ -127,7 +127,7 @@ export abstract class _MatPaginatorBase< get length(): number { return this._length; } - set length(value: number) { + set length(value: NumberInput) { this._length = coerceNumberProperty(value); this._changeDetectorRef.markForCheck(); } @@ -138,7 +138,7 @@ export abstract class _MatPaginatorBase< get pageSize(): number { return this._pageSize; } - set pageSize(value: number) { + set pageSize(value: NumberInput) { this._pageSize = Math.max(coerceNumberProperty(value), 0); this._updateDisplayedPageSizeOptions(); } @@ -160,7 +160,7 @@ export abstract class _MatPaginatorBase< get hidePageSize(): boolean { return this._hidePageSize; } - set hidePageSize(value: boolean) { + set hidePageSize(value: BooleanInput) { this._hidePageSize = coerceBooleanProperty(value); } private _hidePageSize = false; @@ -170,7 +170,7 @@ export abstract class _MatPaginatorBase< get showFirstLastButtons(): boolean { return this._showFirstLastButtons; } - set showFirstLastButtons(value: boolean) { + set showFirstLastButtons(value: BooleanInput) { this._showFirstLastButtons = coerceBooleanProperty(value); } private _showFirstLastButtons = false; @@ -227,7 +227,7 @@ export abstract class _MatPaginatorBase< } const previousPageIndex = this.pageIndex; - this.pageIndex++; + this.pageIndex = this.pageIndex + 1; this._emitPageEvent(previousPageIndex); } @@ -238,7 +238,7 @@ export abstract class _MatPaginatorBase< } const previousPageIndex = this.pageIndex; - this.pageIndex--; + this.pageIndex = this.pageIndex - 1; this._emitPageEvent(previousPageIndex); } @@ -350,13 +350,6 @@ export abstract class _MatPaginatorBase< length: this.length, }); } - - static ngAcceptInputType_pageIndex: NumberInput; - static ngAcceptInputType_length: NumberInput; - static ngAcceptInputType_pageSize: NumberInput; - static ngAcceptInputType_hidePageSize: BooleanInput; - static ngAcceptInputType_showFirstLastButtons: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } /** diff --git a/src/material/progress-bar/progress-bar.ts b/src/material/progress-bar/progress-bar.ts index 3c7c278ca54e..3614ac0576a9 100644 --- a/src/material/progress-bar/progress-bar.ts +++ b/src/material/progress-bar/progress-bar.ts @@ -166,7 +166,7 @@ export class MatProgressBar get value(): number { return this._value; } - set value(v: number) { + set value(v: NumberInput) { this._value = clamp(coerceNumberProperty(v) || 0); } private _value: number = 0; @@ -249,8 +249,6 @@ export class MatProgressBar ngOnDestroy() { this._animationEndSubscription.unsubscribe(); } - - static ngAcceptInputType_value: NumberInput; } /** Clamps a value to be between two numbers, by default 0 and 100. */ diff --git a/src/material/progress-spinner/progress-spinner.ts b/src/material/progress-spinner/progress-spinner.ts index 6feebaf9e23e..568887129ba7 100644 --- a/src/material/progress-spinner/progress-spinner.ts +++ b/src/material/progress-spinner/progress-spinner.ts @@ -157,7 +157,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements OnIni get diameter(): number { return this._diameter; } - set diameter(size: number) { + set diameter(size: NumberInput) { this._diameter = coerceNumberProperty(size); this._spinnerAnimationLabel = this._getSpinnerAnimationLabel(); @@ -172,7 +172,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements OnIni get strokeWidth(): number { return this._strokeWidth || this.diameter / 10; } - set strokeWidth(value: number) { + set strokeWidth(value: NumberInput) { this._strokeWidth = coerceNumberProperty(value); } @@ -184,7 +184,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements OnIni get value(): number { return this.mode === 'determinate' ? this._value : 0; } - set value(newValue: number) { + set value(newValue: NumberInput) { this._value = Math.max(0, Math.min(100, coerceNumberProperty(newValue))); } @@ -306,10 +306,6 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements OnIni // which is not valid for a CSS animation-name. return this.diameter.toString().replace('.', '_'); } - - static ngAcceptInputType_diameter: NumberInput; - static ngAcceptInputType_strokeWidth: NumberInput; - static ngAcceptInputType_value: NumberInput; } /** diff --git a/src/material/radio/radio.ts b/src/material/radio/radio.ts index 16484458a827..5a8b8e91b0ca 100644 --- a/src/material/radio/radio.ts +++ b/src/material/radio/radio.ts @@ -7,12 +7,7 @@ */ import {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; -import { - BooleanInput, - coerceBooleanProperty, - coerceNumberProperty, - NumberInput, -} from '@angular/cdk/coercion'; +import {BooleanInput, coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion'; import {UniqueSelectionDispatcher} from '@angular/cdk/collections'; import { AfterContentInit, @@ -214,7 +209,7 @@ export abstract class _MatRadioGroupBase get disabled(): boolean { return this._disabled; } - set disabled(value) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._markRadiosForCheck(); } @@ -224,7 +219,7 @@ export abstract class _MatRadioGroupBase get required(): boolean { return this._required; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); this._markRadiosForCheck(); } @@ -325,9 +320,6 @@ export abstract class _MatRadioGroupBase this.disabled = isDisabled; this._changeDetector.markForCheck(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_required: BooleanInput; } /** @@ -393,7 +385,7 @@ export abstract class _MatRadioButtonBase get checked(): boolean { return this._checked; } - set checked(value: boolean) { + set checked(value: BooleanInput) { const newCheckedState = coerceBooleanProperty(value); if (this._checked !== newCheckedState) { this._checked = newCheckedState; @@ -448,7 +440,7 @@ export abstract class _MatRadioButtonBase get disabled(): boolean { return this._disabled || (this.radioGroup !== null && this.radioGroup.disabled); } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._setDisabled(coerceBooleanProperty(value)); } @@ -457,7 +449,7 @@ export abstract class _MatRadioButtonBase get required(): boolean { return this._required || (this.radioGroup && this.radioGroup.required); } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } @@ -637,12 +629,6 @@ export abstract class _MatRadioButtonBase this._changeDetector.markForCheck(); } } - - static ngAcceptInputType_checked: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_required: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } /** diff --git a/src/material/select/select.ts b/src/material/select/select.ts index a41cb9faaa11..a907366ab4e1 100644 --- a/src/material/select/select.ts +++ b/src/material/select/select.ts @@ -348,7 +348,7 @@ export abstract class _MatSelectBase get required(): boolean { return this._required ?? this.ngControl?.control?.hasValidator(Validators.required) ?? false; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); this.stateChanges.next(); } @@ -359,7 +359,7 @@ export abstract class _MatSelectBase get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { if (this._selectionModel && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw getMatSelectDynamicMultipleError(); } @@ -373,7 +373,7 @@ export abstract class _MatSelectBase get disableOptionCentering(): boolean { return this._disableOptionCentering; } - set disableOptionCentering(value: boolean) { + set disableOptionCentering(value: BooleanInput) { this._disableOptionCentering = coerceBooleanProperty(value); } private _disableOptionCentering = this._defaultOptions?.disableOptionCentering ?? false; @@ -429,7 +429,7 @@ export abstract class _MatSelectBase get typeaheadDebounceInterval(): number { return this._typeaheadDebounceInterval; } - set typeaheadDebounceInterval(value: number) { + set typeaheadDebounceInterval(value: NumberInput) { this._typeaheadDebounceInterval = coerceNumberProperty(value); } private _typeaheadDebounceInterval: number; @@ -1117,14 +1117,6 @@ export abstract class _MatSelectBase get shouldLabelFloat(): boolean { return this._panelOpen || !this.empty || (this._focused && !!this._placeholder); } - - static ngAcceptInputType_required: BooleanInput; - static ngAcceptInputType_multiple: BooleanInput; - static ngAcceptInputType_disableOptionCentering: BooleanInput; - static ngAcceptInputType_typeaheadDebounceInterval: NumberInput; - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } @Component({ diff --git a/src/material/sidenav/drawer.ts b/src/material/sidenav/drawer.ts index 2989dbd1f697..425c9d9d9ed8 100644 --- a/src/material/sidenav/drawer.ts +++ b/src/material/sidenav/drawer.ts @@ -186,7 +186,7 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr get disableClose(): boolean { return this._disableClose; } - set disableClose(value: boolean) { + set disableClose(value: BooleanInput) { this._disableClose = coerceBooleanProperty(value); } private _disableClose: boolean = false; @@ -214,8 +214,8 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr } return value; } - set autoFocus(value: AutoFocusTarget | string | boolean) { - if (value === 'true' || value === 'false') { + set autoFocus(value: AutoFocusTarget | string | BooleanInput) { + if (value === 'true' || value === 'false' || value == null) { value = coerceBooleanProperty(value); } this._autoFocus = value; @@ -230,7 +230,7 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr get opened(): boolean { return this._opened; } - set opened(value: boolean) { + set opened(value: BooleanInput) { this.toggle(coerceBooleanProperty(value)); } private _opened: boolean = false; @@ -561,10 +561,6 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr this._focusTrap.enabled = this.opened && this.mode !== 'side'; } } - - static ngAcceptInputType_disableClose: BooleanInput; - static ngAcceptInputType_autoFocus: AutoFocusTarget | string | BooleanInput; - static ngAcceptInputType_opened: BooleanInput; } /** @@ -628,7 +624,7 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy get autosize(): boolean { return this._autosize; } - set autosize(value: boolean) { + set autosize(value: BooleanInput) { this._autosize = coerceBooleanProperty(value); } private _autosize: boolean; @@ -639,14 +635,14 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy * mode as well. */ @Input() - get hasBackdrop() { + get hasBackdrop(): boolean { if (this._backdropOverride == null) { return !this._start || this._start.mode !== 'side' || !this._end || this._end.mode !== 'side'; } return this._backdropOverride; } - set hasBackdrop(value: any) { + set hasBackdrop(value: BooleanInput) { this._backdropOverride = value == null ? null : coerceBooleanProperty(value); } _backdropOverride: boolean | null; @@ -965,7 +961,4 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy private _isDrawerOpen(drawer: MatDrawer | null): drawer is MatDrawer { return drawer != null && drawer.opened; } - - static ngAcceptInputType_autosize: BooleanInput; - static ngAcceptInputType_hasBackdrop: BooleanInput; } diff --git a/src/material/sidenav/sidenav.ts b/src/material/sidenav/sidenav.ts index 66d2402fc185..a18b6d682e37 100644 --- a/src/material/sidenav/sidenav.ts +++ b/src/material/sidenav/sidenav.ts @@ -81,7 +81,7 @@ export class MatSidenav extends MatDrawer { get fixedInViewport(): boolean { return this._fixedInViewport; } - set fixedInViewport(value) { + set fixedInViewport(value: BooleanInput) { this._fixedInViewport = coerceBooleanProperty(value); } private _fixedInViewport = false; @@ -94,7 +94,7 @@ export class MatSidenav extends MatDrawer { get fixedTopGap(): number { return this._fixedTopGap; } - set fixedTopGap(value) { + set fixedTopGap(value: NumberInput) { this._fixedTopGap = coerceNumberProperty(value); } private _fixedTopGap = 0; @@ -107,14 +107,10 @@ export class MatSidenav extends MatDrawer { get fixedBottomGap(): number { return this._fixedBottomGap; } - set fixedBottomGap(value) { + set fixedBottomGap(value: NumberInput) { this._fixedBottomGap = coerceNumberProperty(value); } private _fixedBottomGap = 0; - - static ngAcceptInputType_fixedInViewport: BooleanInput; - static ngAcceptInputType_fixedTopGap: NumberInput; - static ngAcceptInputType_fixedBottomGap: NumberInput; } @Component({ diff --git a/src/material/slide-toggle/slide-toggle.ts b/src/material/slide-toggle/slide-toggle.ts index 6cb2215e3c24..426a9a26ada0 100644 --- a/src/material/slide-toggle/slide-toggle.ts +++ b/src/material/slide-toggle/slide-toggle.ts @@ -7,7 +7,7 @@ */ import {FocusMonitor, FocusOrigin} from '@angular/cdk/a11y'; -import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion'; +import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import { AfterContentInit, Attribute, @@ -149,7 +149,7 @@ export class MatSlideToggle get required(): boolean { return this._required; } - set required(value) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } @@ -158,7 +158,7 @@ export class MatSlideToggle get checked(): boolean { return this._checked; } - set checked(value) { + set checked(value: BooleanInput) { this._checked = coerceBooleanProperty(value); this._changeDetectorRef.markForCheck(); } @@ -302,10 +302,4 @@ export class MatSlideToggle // we only trigger an explicit change detection for the slide-toggle view and its children. this._changeDetectorRef.detectChanges(); } - - static ngAcceptInputType_required: BooleanInput; - static ngAcceptInputType_checked: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } diff --git a/src/material/slider/slider.ts b/src/material/slider/slider.ts index 1c7e547c00f3..4fb7650df091 100644 --- a/src/material/slider/slider.ts +++ b/src/material/slider/slider.ts @@ -170,7 +170,7 @@ export class MatSlider get invert(): boolean { return this._invert; } - set invert(value: boolean) { + set invert(value: BooleanInput) { this._invert = coerceBooleanProperty(value); } private _invert = false; @@ -180,7 +180,7 @@ export class MatSlider get max(): number { return this._max; } - set max(v: number) { + set max(v: NumberInput) { this._max = coerceNumberProperty(v, this._max); this._percent = this._calculatePercentage(this._value); @@ -194,7 +194,7 @@ export class MatSlider get min(): number { return this._min; } - set min(v: number) { + set min(v: NumberInput) { this._min = coerceNumberProperty(v, this._min); this._percent = this._calculatePercentage(this._value); @@ -208,7 +208,7 @@ export class MatSlider get step(): number { return this._step; } - set step(v: number) { + set step(v: NumberInput) { this._step = coerceNumberProperty(v, this._step); if (this._step % 1 !== 0) { @@ -225,7 +225,7 @@ export class MatSlider get thumbLabel(): boolean { return this._thumbLabel; } - set thumbLabel(value: boolean) { + set thumbLabel(value: BooleanInput) { this._thumbLabel = coerceBooleanProperty(value); } private _thumbLabel: boolean = false; @@ -235,10 +235,10 @@ export class MatSlider * Ex: Tick interval of 4 with a step of 3 will draw a tick every 4 steps (every 12 values). */ @Input() - get tickInterval() { + get tickInterval(): 'auto' | number { return this._tickInterval; } - set tickInterval(value: 'auto' | number) { + set tickInterval(value: 'auto' | NumberInput) { if (value === 'auto') { this._tickInterval = 'auto'; } else if (typeof value === 'number' || typeof value === 'string') { @@ -258,7 +258,7 @@ export class MatSlider } return this._value as number; } - set value(v: number) { + set value(v: NumberInput) { if (v !== this._value) { let value = coerceNumberProperty(v, 0); @@ -292,7 +292,7 @@ export class MatSlider get vertical(): boolean { return this._vertical; } - set vertical(value: boolean) { + set vertical(value: BooleanInput) { this._vertical = coerceBooleanProperty(value); } private _vertical = false; @@ -943,17 +943,6 @@ export class MatSlider setDisabledState(isDisabled: boolean) { this.disabled = isDisabled; } - - static ngAcceptInputType_invert: BooleanInput; - static ngAcceptInputType_max: NumberInput; - static ngAcceptInputType_min: NumberInput; - static ngAcceptInputType_step: NumberInput; - static ngAcceptInputType_thumbLabel: BooleanInput; - static ngAcceptInputType_tickInterval: NumberInput; - static ngAcceptInputType_value: NumberInput; - static ngAcceptInputType_vertical: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } /** Returns whether an event is a touch event. */ diff --git a/src/material/sort/sort-header.ts b/src/material/sort/sort-header.ts index d953f8b88ec7..3ece3422dde2 100644 --- a/src/material/sort/sort-header.ts +++ b/src/material/sort/sort-header.ts @@ -160,7 +160,7 @@ export class MatSortHeader get disableClear(): boolean { return this._disableClear; } - set disableClear(v) { + set disableClear(v: BooleanInput) { this._disableClear = coerceBooleanProperty(v); } private _disableClear: boolean; @@ -392,7 +392,4 @@ export class MatSortHeader this._changeDetectorRef.markForCheck(); }); } - - static ngAcceptInputType_disableClear: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material/sort/sort.ts b/src/material/sort/sort.ts index 7806253c35af..30e1e223c0d0 100644 --- a/src/material/sort/sort.ts +++ b/src/material/sort/sort.ts @@ -116,7 +116,7 @@ export class MatSort get disableClear(): boolean { return this._disableClear; } - set disableClear(v: boolean) { + set disableClear(v: BooleanInput) { this._disableClear = coerceBooleanProperty(v); } private _disableClear: boolean; @@ -200,9 +200,6 @@ export class MatSort ngOnDestroy() { this._stateChanges.complete(); } - - static ngAcceptInputType_disableClear: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } /** Returns the sort direction cycle to use given the provided parameters of order and clear. */ diff --git a/src/material/tabs/paginated-tab-header.ts b/src/material/tabs/paginated-tab-header.ts index 5fed642cf5b7..184e4162e7aa 100644 --- a/src/material/tabs/paginated-tab-header.ts +++ b/src/material/tabs/paginated-tab-header.ts @@ -127,7 +127,7 @@ export abstract class MatPaginatedTabHeader get selectedIndex(): number { return this._selectedIndex; } - set selectedIndex(value: number) { + set selectedIndex(value: NumberInput) { value = coerceNumberProperty(value); if (this._selectedIndex != value) { @@ -596,6 +596,4 @@ export abstract class MatPaginatedTabHeader return {maxScrollDistance, distance: this._scrollDistance}; } - - static ngAcceptInputType_selectedIndex: NumberInput; } diff --git a/src/material/tabs/tab-group.ts b/src/material/tabs/tab-group.ts index f77af0c0c543..318ae407779f 100644 --- a/src/material/tabs/tab-group.ts +++ b/src/material/tabs/tab-group.ts @@ -112,7 +112,7 @@ export abstract class _MatTabGroupBase get dynamicHeight(): boolean { return this._dynamicHeight; } - set dynamicHeight(value: boolean) { + set dynamicHeight(value: BooleanInput) { this._dynamicHeight = coerceBooleanProperty(value); } private _dynamicHeight: boolean; @@ -122,7 +122,7 @@ export abstract class _MatTabGroupBase get selectedIndex(): number | null { return this._selectedIndex; } - set selectedIndex(value: number | null) { + set selectedIndex(value: NumberInput) { this._indexToSelect = coerceNumberProperty(value, null); } private _selectedIndex: number | null = null; @@ -135,8 +135,8 @@ export abstract class _MatTabGroupBase get animationDuration(): string { return this._animationDuration; } - set animationDuration(value: string) { - this._animationDuration = /^\d+$/.test(value) ? value + 'ms' : value; + set animationDuration(value: NumberInput) { + this._animationDuration = /^\d+$/.test(value + '') ? value + 'ms' : (value as string); } private _animationDuration: string; @@ -150,7 +150,7 @@ export abstract class _MatTabGroupBase get contentTabIndex(): number | null { return this._contentTabIndex; } - set contentTabIndex(value: number | null) { + set contentTabIndex(value: NumberInput) { this._contentTabIndex = coerceNumberProperty(value, null); } private _contentTabIndex: number | null; @@ -439,12 +439,6 @@ export abstract class _MatTabGroupBase this._tabHeader.focusIndex = index; } } - - static ngAcceptInputType_dynamicHeight: BooleanInput; - static ngAcceptInputType_animationDuration: NumberInput; - static ngAcceptInputType_selectedIndex: NumberInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_contentTabIndex: NumberInput; } /** diff --git a/src/material/tabs/tab-header.ts b/src/material/tabs/tab-header.ts index 339a8ead2b81..7a7062b77d49 100644 --- a/src/material/tabs/tab-header.ts +++ b/src/material/tabs/tab-header.ts @@ -45,10 +45,10 @@ export abstract class _MatTabHeaderBase { /** Whether the ripple effect is disabled or not. */ @Input() - get disableRipple() { + get disableRipple(): boolean { return this._disableRipple; } - set disableRipple(value: any) { + set disableRipple(value: BooleanInput) { this._disableRipple = coerceBooleanProperty(value); } private _disableRipple: boolean = false; @@ -112,6 +112,4 @@ export class MatTabHeader extends _MatTabHeaderBase { ) { super(elementRef, changeDetectorRef, viewportRuler, dir, ngZone, platform, animationMode); } - - static ngAcceptInputType_disableRipple: BooleanInput; } diff --git a/src/material/tabs/tab-label-wrapper.ts b/src/material/tabs/tab-label-wrapper.ts index 3b9914de6f38..0ae024e09126 100644 --- a/src/material/tabs/tab-label-wrapper.ts +++ b/src/material/tabs/tab-label-wrapper.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {BooleanInput} from '@angular/cdk/coercion'; import {Directive, ElementRef} from '@angular/core'; import {CanDisable, mixinDisabled} from '@angular/material/core'; @@ -43,6 +42,4 @@ export class MatTabLabelWrapper extends _MatTabLabelWrapperBase implements CanDi getOffsetWidth(): number { return this.elementRef.nativeElement.offsetWidth; } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material/tabs/tab-nav-bar/tab-nav-bar.ts b/src/material/tabs/tab-nav-bar/tab-nav-bar.ts index 06a59fd470f2..ffc5b573535a 100644 --- a/src/material/tabs/tab-nav-bar/tab-nav-bar.ts +++ b/src/material/tabs/tab-nav-bar/tab-nav-bar.ts @@ -7,7 +7,7 @@ */ import {FocusableOption, FocusMonitor} from '@angular/cdk/a11y'; import {Directionality} from '@angular/cdk/bidi'; -import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion'; +import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; import {Platform} from '@angular/cdk/platform'; import {ViewportRuler} from '@angular/cdk/scrolling'; import { @@ -81,10 +81,10 @@ export abstract class _MatTabNavBase /** Whether the ripple effect is disabled or not. */ @Input() - get disableRipple() { + get disableRipple(): boolean { return this._disableRipple; } - set disableRipple(value: any) { + set disableRipple(value: BooleanInput) { this._disableRipple = coerceBooleanProperty(value); } private _disableRipple: boolean = false; @@ -182,8 +182,6 @@ export class MatTabNav extends _MatTabNavBase { ) { super(elementRef, dir, ngZone, changeDetectorRef, viewportRuler, platform, animationMode); } - - static ngAcceptInputType_disableRipple: BooleanInput; } // Boilerplate for applying mixins to MatTabLink. @@ -210,11 +208,11 @@ export class _MatTabLinkBase get active(): boolean { return this._isActive; } - set active(value: boolean) { + set active(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._isActive) { - this._isActive = value; + this._isActive = newValue; this._tabNavBar.updateActiveLink(); } } @@ -276,11 +274,6 @@ export class _MatTabLinkBase // have to update the focused index whenever the link receives focus. this._tabNavBar.focusIndex = this._tabNavBar._items.toArray().indexOf(this); } - - static ngAcceptInputType_active: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } /** diff --git a/src/material/tabs/tab.ts b/src/material/tabs/tab.ts index 5f6019879b13..5378b7f898d6 100644 --- a/src/material/tabs/tab.ts +++ b/src/material/tabs/tab.ts @@ -6,7 +6,6 @@ * found in the LICENSE file at https://angular.io/license */ -import {BooleanInput} from '@angular/cdk/coercion'; import {TemplatePortal} from '@angular/cdk/portal'; import { ChangeDetectionStrategy, @@ -149,6 +148,4 @@ export class MatTab extends _MatTabBase implements OnInit, CanDisable, OnChanges this._templateLabel = value; } } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material/tooltip/tooltip.ts b/src/material/tooltip/tooltip.ts index 55a735e9aaad..e14392633e8d 100644 --- a/src/material/tooltip/tooltip.ts +++ b/src/material/tooltip/tooltip.ts @@ -8,7 +8,12 @@ import {AnimationEvent} from '@angular/animations'; import {AriaDescriber, FocusMonitor} from '@angular/cdk/a11y'; import {Directionality} from '@angular/cdk/bidi'; -import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion'; +import { + BooleanInput, + coerceBooleanProperty, + coerceNumberProperty, + NumberInput, +} from '@angular/cdk/coercion'; import {ESCAPE, hasModifierKey} from '@angular/cdk/keycodes'; import {BreakpointObserver, Breakpoints, BreakpointState} from '@angular/cdk/layout'; import { @@ -174,7 +179,7 @@ export abstract class _MatTooltipBase get disabled(): boolean { return this._disabled; } - set disabled(value) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); // If tooltip is disabled, hide immediately. @@ -186,10 +191,24 @@ export abstract class _MatTooltipBase } /** The default delay in ms before showing the tooltip after show is called */ - @Input('matTooltipShowDelay') showDelay: number = this._defaultOptions.showDelay; + @Input('matTooltipShowDelay') + get showDelay(): number { + return this._showDelay; + } + set showDelay(value: NumberInput) { + this._showDelay = coerceNumberProperty(value); + } + private _showDelay = this._defaultOptions.showDelay; /** The default delay in ms before hiding the tooltip after hide is called */ - @Input('matTooltipHideDelay') hideDelay: number = this._defaultOptions.hideDelay; + @Input('matTooltipHideDelay') + get hideDelay(): number { + return this._hideDelay; + } + set hideDelay(value: NumberInput) { + this._hideDelay = coerceNumberProperty(value); + } + private _hideDelay = this._defaultOptions.hideDelay; /** * How touch gestures should be handled by the tooltip. On touch devices the tooltip directive @@ -745,10 +764,6 @@ export abstract class _MatTooltipBase (style as any).webkitTapHighlightColor = 'transparent'; } } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_hideDelay: NumberInput; - static ngAcceptInputType_showDelay: NumberInput; } /** diff --git a/src/material/tree/node.ts b/src/material/tree/node.ts index ecec48805e84..437596f6add5 100644 --- a/src/material/tree/node.ts +++ b/src/material/tree/node.ts @@ -24,7 +24,7 @@ import { OnInit, } from '@angular/core'; import {CanDisable, HasTabIndex, mixinDisabled, mixinTabIndex} from '@angular/material/core'; -import {BooleanInput, coerceBooleanProperty, NumberInput} from '@angular/cdk/coercion'; +import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion'; const _MatTreeNodeBase = mixinTabIndex(mixinDisabled(CdkTreeNode)); @@ -62,9 +62,6 @@ export class MatTreeNode override ngOnDestroy() { super.ngOnDestroy(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } /** @@ -104,10 +101,10 @@ export class MatNestedTreeNode /** Whether the node is disabled. */ @Input() - get disabled() { + get disabled(): boolean { return this._disabled; } - set disabled(value: any) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; @@ -147,6 +144,4 @@ export class MatNestedTreeNode override ngOnDestroy() { super.ngOnDestroy(); } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material/tree/padding.ts b/src/material/tree/padding.ts index ae7bdee5798a..65a98cf6e37c 100644 --- a/src/material/tree/padding.ts +++ b/src/material/tree/padding.ts @@ -5,6 +5,7 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ +import {NumberInput} from '@angular/cdk/coercion'; import {CdkTreeNodePadding} from '@angular/cdk/tree'; import {Directive, Input} from '@angular/core'; @@ -21,7 +22,7 @@ export class MatTreeNodePadding extends CdkTreeNodePadding { override get level(): number { return this._level; } - override set level(value: number) { + override set level(value: NumberInput) { this._setLevelInput(value); } diff --git a/tools/dgeni/common/private-docs.ts b/tools/dgeni/common/private-docs.ts index 14c5b87b13e4..435a213db99f 100644 --- a/tools/dgeni/common/private-docs.ts +++ b/tools/dgeni/common/private-docs.ts @@ -39,11 +39,7 @@ export function isPublicDoc(doc: ApiDoc) { return true; } - if ( - _hasDocsPrivateTag(doc) || - doc.name.startsWith('_') || - doc.name.startsWith('ngAcceptInputType_') - ) { + if (_hasDocsPrivateTag(doc) || doc.name.startsWith('_')) { return false; } else if (doc instanceof MemberDoc) { return !_isInternalMember(doc); diff --git a/tools/public_api_guard/cdk/a11y.md b/tools/public_api_guard/cdk/a11y.md index 4e3ef6b329a4..39dddbe4303c 100644 --- a/tools/public_api_guard/cdk/a11y.md +++ b/tools/public_api_guard/cdk/a11y.md @@ -97,15 +97,11 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit, OnChanges, DoC constructor(_elementRef: ElementRef, _focusTrapFactory: FocusTrapFactory, _document: any); get autoCapture(): boolean; - set autoCapture(value: boolean); + set autoCapture(value: BooleanInput); get enabled(): boolean; - set enabled(value: boolean); + set enabled(value: BooleanInput); focusTrap: FocusTrap; // (undocumented) - static ngAcceptInputType_autoCapture: BooleanInput; - // (undocumented) - static ngAcceptInputType_enabled: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngDoCheck(): void; diff --git a/tools/public_api_guard/cdk/accordion.md b/tools/public_api_guard/cdk/accordion.md index b38efe9b32e3..18c5098577b8 100644 --- a/tools/public_api_guard/cdk/accordion.md +++ b/tools/public_api_guard/cdk/accordion.md @@ -23,9 +23,7 @@ export class CdkAccordion implements OnDestroy, OnChanges { closeAll(): void; readonly id: string; get multi(): boolean; - set multi(multi: boolean); - // (undocumented) - static ngAcceptInputType_multi: BooleanInput; + set multi(multi: BooleanInput); // (undocumented) ngOnChanges(changes: SimpleChanges): void; // (undocumented) @@ -48,17 +46,13 @@ export class CdkAccordionItem implements OnDestroy { readonly closed: EventEmitter; readonly destroyed: EventEmitter; get disabled(): boolean; - set disabled(disabled: boolean); + set disabled(disabled: BooleanInput); get expanded(): boolean; - set expanded(expanded: boolean); + set expanded(expanded: BooleanInput); readonly expandedChange: EventEmitter; // (undocumented) protected _expansionDispatcher: UniqueSelectionDispatcher; readonly id: string; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_expanded: BooleanInput; ngOnDestroy(): void; open(): void; readonly opened: EventEmitter; diff --git a/tools/public_api_guard/cdk/drag-drop.md b/tools/public_api_guard/cdk/drag-drop.md index 684bf9a0e279..09aa41614efe 100644 --- a/tools/public_api_guard/cdk/drag-drop.md +++ b/tools/public_api_guard/cdk/drag-drop.md @@ -58,7 +58,7 @@ export class CdkDrag implements AfterViewInit, OnChanges, OnDestroy { constrainPosition?: (point: Point, dragRef: DragRef) => Point; data: T; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); _dragRef: DragRef>; dragStartDelay: DragStartDelay; dropContainer: CdkDropListInternal; @@ -81,8 +81,6 @@ export class CdkDrag implements AfterViewInit, OnChanges, OnDestroy { lockAxis: DragAxis; readonly moved: Observable>; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnChanges(changes: SimpleChanges): void; @@ -150,12 +148,10 @@ export interface CdkDragExit { export class CdkDragHandle implements OnDestroy { constructor(element: ElementRef, parentDrag?: any); get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); // (undocumented) element: ElementRef; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngOnDestroy(): void; _parentDrag: {} | undefined; readonly _stateChanges: Subject; @@ -200,9 +196,7 @@ export class CdkDragPreview { constructor(templateRef: TemplateRef); data: T; get matchSize(): boolean; - set matchSize(value: boolean); - // (undocumented) - static ngAcceptInputType_matchSize: BooleanInput; + set matchSize(value: BooleanInput); // (undocumented) templateRef: TemplateRef; // (undocumented) @@ -234,12 +228,12 @@ export class CdkDropList implements OnDestroy { constructor( element: ElementRef, dragDrop: DragDrop, _changeDetectorRef: ChangeDetectorRef, _scrollDispatcher: ScrollDispatcher, _dir?: Directionality | undefined, _group?: CdkDropListGroup> | undefined, config?: DragDropConfig); addItem(item: CdkDrag): void; - autoScrollDisabled: boolean; - autoScrollStep: number; + autoScrollDisabled: BooleanInput; + autoScrollStep: NumberInput; connectedTo: (CdkDropList | string)[] | CdkDropList | string; data: T; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); _dropListRef: DropListRef>; readonly dropped: EventEmitter>; element: ElementRef; @@ -250,19 +244,11 @@ export class CdkDropList implements OnDestroy { id: string; lockAxis: DragAxis; // (undocumented) - static ngAcceptInputType_autoScrollDisabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_autoScrollStep: NumberInput; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_sortingDisabled: BooleanInput; - // (undocumented) ngOnDestroy(): void; orientation: DropListOrientation; removeItem(item: CdkDrag): void; readonly sorted: EventEmitter>; - sortingDisabled: boolean; + sortingDisabled: BooleanInput; sortPredicate: (index: number, drag: CdkDrag, drop: CdkDropList) => boolean; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "[cdkDropList], cdk-drop-list", ["cdkDropList"], { "connectedTo": "cdkDropListConnectedTo"; "data": "cdkDropListData"; "orientation": "cdkDropListOrientation"; "id": "id"; "lockAxis": "cdkDropListLockAxis"; "disabled": "cdkDropListDisabled"; "sortingDisabled": "cdkDropListSortingDisabled"; "enterPredicate": "cdkDropListEnterPredicate"; "sortPredicate": "cdkDropListSortPredicate"; "autoScrollDisabled": "cdkDropListAutoScrollDisabled"; "autoScrollStep": "cdkDropListAutoScrollStep"; }, { "dropped": "cdkDropListDropped"; "entered": "cdkDropListEntered"; "exited": "cdkDropListExited"; "sorted": "cdkDropListSorted"; }, never>; @@ -273,11 +259,9 @@ export class CdkDropList implements OnDestroy { // @public export class CdkDropListGroup implements OnDestroy { get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); readonly _items: Set; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngOnDestroy(): void; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "[cdkDropListGroup]", ["cdkDropListGroup"], { "disabled": "cdkDropListGroupDisabled"; }, {}, never>; diff --git a/tools/public_api_guard/cdk/observers.md b/tools/public_api_guard/cdk/observers.md index 9fdcf38a3995..2dc6c5d7a38a 100644 --- a/tools/public_api_guard/cdk/observers.md +++ b/tools/public_api_guard/cdk/observers.md @@ -18,15 +18,11 @@ import { OnDestroy } from '@angular/core'; export class CdkObserveContent implements AfterContentInit, OnDestroy { constructor(_contentObserver: ContentObserver, _elementRef: ElementRef, _ngZone: NgZone); get debounce(): number; - set debounce(value: number); - get disabled(): any; - set disabled(value: any); + set debounce(value: NumberInput); + get disabled(): boolean; + set disabled(value: BooleanInput); readonly event: EventEmitter; // (undocumented) - static ngAcceptInputType_debounce: NumberInput; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnDestroy(): void; diff --git a/tools/public_api_guard/cdk/overlay.md b/tools/public_api_guard/cdk/overlay.md index cf6ea72a5d20..79adbbb8d438 100644 --- a/tools/public_api_guard/cdk/overlay.md +++ b/tools/public_api_guard/cdk/overlay.md @@ -68,27 +68,17 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges { get dir(): Direction; disableClose: boolean; get flexibleDimensions(): boolean; - set flexibleDimensions(value: boolean); + set flexibleDimensions(value: BooleanInput); get growAfterOpen(): boolean; - set growAfterOpen(value: boolean); - get hasBackdrop(): any; - set hasBackdrop(value: any); + set growAfterOpen(value: BooleanInput); + get hasBackdrop(): boolean; + set hasBackdrop(value: BooleanInput); height: number | string; - get lockPosition(): any; - set lockPosition(value: any); + get lockPosition(): boolean; + set lockPosition(value: BooleanInput); minHeight: number | string; minWidth: number | string; // (undocumented) - static ngAcceptInputType_flexibleDimensions: BooleanInput; - // (undocumented) - static ngAcceptInputType_growAfterOpen: BooleanInput; - // (undocumented) - static ngAcceptInputType_hasBackdrop: BooleanInput; - // (undocumented) - static ngAcceptInputType_lockPosition: BooleanInput; - // (undocumented) - static ngAcceptInputType_push: BooleanInput; - // (undocumented) ngOnChanges(changes: SimpleChanges): void; // (undocumented) ngOnDestroy(): void; @@ -106,7 +96,7 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges { positions: ConnectedPosition[]; positionStrategy: FlexibleConnectedPositionStrategy; get push(): boolean; - set push(value: boolean); + set push(value: BooleanInput); scrollStrategy: ScrollStrategy; transformOriginSelector: string; viewportMargin: number; diff --git a/tools/public_api_guard/cdk/portal.md b/tools/public_api_guard/cdk/portal.md index cd583e0c616d..71b106338faf 100644 --- a/tools/public_api_guard/cdk/portal.md +++ b/tools/public_api_guard/cdk/portal.md @@ -62,13 +62,11 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr get attachedRef(): CdkPortalOutletAttachedRef; attachTemplatePortal(portal: TemplatePortal): EmbeddedViewRef; // (undocumented) - static ngAcceptInputType_portal: Portal | null | undefined | ''; - // (undocumented) ngOnDestroy(): void; // (undocumented) ngOnInit(): void; get portal(): Portal | null; - set portal(portal: Portal | null); + set portal(portal: Portal | null | undefined | ''); // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) diff --git a/tools/public_api_guard/cdk/scrolling.md b/tools/public_api_guard/cdk/scrolling.md index b1c6b36e5c92..2b729d0fbc7a 100644 --- a/tools/public_api_guard/cdk/scrolling.md +++ b/tools/public_api_guard/cdk/scrolling.md @@ -40,24 +40,18 @@ export type _Bottom = { // @public export class CdkFixedSizeVirtualScroll implements OnChanges { get itemSize(): number; - set itemSize(value: number); + set itemSize(value: NumberInput); // (undocumented) _itemSize: number; get maxBufferPx(): number; - set maxBufferPx(value: number); + set maxBufferPx(value: NumberInput); // (undocumented) _maxBufferPx: number; get minBufferPx(): number; - set minBufferPx(value: number); + set minBufferPx(value: NumberInput); // (undocumented) _minBufferPx: number; // (undocumented) - static ngAcceptInputType_itemSize: NumberInput; - // (undocumented) - static ngAcceptInputType_maxBufferPx: NumberInput; - // (undocumented) - static ngAcceptInputType_minBufferPx: NumberInput; - // (undocumented) ngOnChanges(): void; _scrollStrategy: FixedSizeVirtualScrollStrategy; // (undocumented) @@ -115,14 +109,12 @@ export class CdkVirtualForOf implements CdkVirtualScrollRepeater, Collecti _cdkVirtualForOf: DataSource | Observable | NgIterable | null | undefined; set cdkVirtualForTemplate(value: TemplateRef>); get cdkVirtualForTemplateCacheSize(): number; - set cdkVirtualForTemplateCacheSize(size: number); + set cdkVirtualForTemplateCacheSize(size: NumberInput); get cdkVirtualForTrackBy(): TrackByFunction | undefined; set cdkVirtualForTrackBy(fn: TrackByFunction | undefined); readonly dataStream: Observable; measureRangeSize(range: ListRange, orientation: 'horizontal' | 'vertical'): number; // (undocumented) - static ngAcceptInputType_cdkVirtualForTemplateCacheSize: NumberInput; - // (undocumented) ngDoCheck(): void; // (undocumented) ngOnDestroy(): void; @@ -157,7 +149,7 @@ export interface CdkVirtualScrollRepeater { export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, OnDestroy { constructor(elementRef: ElementRef, _changeDetectorRef: ChangeDetectorRef, ngZone: NgZone, _scrollStrategy: VirtualScrollStrategy, dir: Directionality, scrollDispatcher: ScrollDispatcher, viewportRuler: ViewportRuler); get appendOnly(): boolean; - set appendOnly(value: boolean); + set appendOnly(value: BooleanInput); attach(forOf: CdkVirtualScrollRepeater): void; checkViewportSize(): void; _contentWrapper: ElementRef; @@ -172,8 +164,6 @@ export class CdkVirtualScrollViewport extends CdkScrollable implements OnInit, O measureRenderedContentSize(): number; measureScrollOffset(from?: 'top' | 'left' | 'right' | 'bottom' | 'start' | 'end'): number; // (undocumented) - static ngAcceptInputType_appendOnly: BooleanInput; - // (undocumented) ngOnDestroy(): void; // (undocumented) ngOnInit(): void; diff --git a/tools/public_api_guard/cdk/stepper.md b/tools/public_api_guard/cdk/stepper.md index a94e3e2ad480..43248b6c63d9 100644 --- a/tools/public_api_guard/cdk/stepper.md +++ b/tools/public_api_guard/cdk/stepper.md @@ -29,34 +29,26 @@ export class CdkStep implements OnChanges { ariaLabel: string; ariaLabelledby: string; get completed(): boolean; - set completed(value: boolean); + set completed(value: BooleanInput); // (undocumented) _completedOverride: boolean | null; content: TemplateRef; // (undocumented) _displayDefaultIndicatorType: boolean; get editable(): boolean; - set editable(value: boolean); + set editable(value: BooleanInput); errorMessage: string; get hasError(): boolean; - set hasError(value: boolean); + set hasError(value: BooleanInput); interacted: boolean; readonly interactedStream: EventEmitter; label: string; // (undocumented) _markAsInteracted(): void; // (undocumented) - static ngAcceptInputType_completed: BooleanInput; - // (undocumented) - static ngAcceptInputType_editable: BooleanInput; - // (undocumented) - static ngAcceptInputType_hasError: BooleanInput; - // (undocumented) - static ngAcceptInputType_optional: BooleanInput; - // (undocumented) ngOnChanges(): void; get optional(): boolean; - set optional(value: boolean); + set optional(value: BooleanInput); reset(): void; select(): void; _showError(): boolean; @@ -106,21 +98,9 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy { _getStepLabelId(i: number): string; _groupId: number; get linear(): boolean; - set linear(value: boolean); + set linear(value: BooleanInput); next(): void; // (undocumented) - static ngAcceptInputType_completed: BooleanInput; - // (undocumented) - static ngAcceptInputType_editable: BooleanInput; - // (undocumented) - static ngAcceptInputType_hasError: BooleanInput; - // (undocumented) - static ngAcceptInputType_linear: BooleanInput; - // (undocumented) - static ngAcceptInputType_optional: BooleanInput; - // (undocumented) - static ngAcceptInputType_selectedIndex: NumberInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngAfterViewInit(): void; @@ -137,7 +117,7 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy { get selected(): CdkStep | undefined; set selected(step: CdkStep | undefined); get selectedIndex(): number; - set selectedIndex(index: number); + set selectedIndex(index: NumberInput); readonly selectionChange: EventEmitter; _stateChanged(): void; _stepHeader: QueryList; diff --git a/tools/public_api_guard/cdk/table.md b/tools/public_api_guard/cdk/table.md index 8d459ff891f3..24ced016d863 100644 --- a/tools/public_api_guard/cdk/table.md +++ b/tools/public_api_guard/cdk/table.md @@ -149,13 +149,9 @@ export class CdkColumnDef extends _CdkColumnDefBase implements CanStick { set name(name: string); // (undocumented) protected _name: string; - // (undocumented) - static ngAcceptInputType_sticky: BooleanInput; - // (undocumented) - static ngAcceptInputType_stickyEnd: BooleanInput; protected _setNameInput(value: string): void; get stickyEnd(): boolean; - set stickyEnd(v: boolean); + set stickyEnd(v: BooleanInput); // (undocumented) _stickyEnd: boolean; // (undocumented) @@ -199,8 +195,6 @@ export class CdkFooterRow { export class CdkFooterRowDef extends _CdkFooterRowDefBase implements CanStick, OnChanges { constructor(template: TemplateRef, _differs: IterableDiffers, _table?: any); // (undocumented) - static ngAcceptInputType_sticky: BooleanInput; - // (undocumented) ngOnChanges(changes: SimpleChanges): void; // (undocumented) _table?: any; @@ -242,8 +236,6 @@ export class CdkHeaderRow { export class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick, OnChanges { constructor(template: TemplateRef, _differs: IterableDiffers, _table?: any); // (undocumented) - static ngAcceptInputType_sticky: BooleanInput; - // (undocumented) ngOnChanges(changes: SimpleChanges): void; // (undocumented) _table?: any; @@ -321,7 +313,7 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes // (undocumented) protected readonly _elementRef: ElementRef; get fixedLayout(): boolean; - set fixedLayout(v: boolean); + set fixedLayout(v: BooleanInput); // (undocumented) _footerRowOutlet: FooterRowOutlet; _getRenderedRows(rowOutlet: RowOutlet): HTMLElement[]; @@ -330,15 +322,11 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes _headerRowOutlet: HeaderRowOutlet; protected _isNativeHtmlTable: boolean; get multiTemplateDataRows(): boolean; - set multiTemplateDataRows(v: boolean); + set multiTemplateDataRows(v: BooleanInput); // (undocumented) _multiTemplateDataRows: boolean; protected needsPositionStickyOnElement: boolean; // (undocumented) - static ngAcceptInputType_fixedLayout: BooleanInput; - // (undocumented) - static ngAcceptInputType_multiTemplateDataRows: BooleanInput; - // (undocumented) ngAfterContentChecked(): void; // (undocumented) ngOnDestroy(): void; diff --git a/tools/public_api_guard/cdk/text-field.md b/tools/public_api_guard/cdk/text-field.md index 00049dfdd373..b9e09078050e 100644 --- a/tools/public_api_guard/cdk/text-field.md +++ b/tools/public_api_guard/cdk/text-field.md @@ -59,17 +59,11 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy { document?: any); protected _document?: Document; get enabled(): boolean; - set enabled(value: boolean); + set enabled(value: BooleanInput); get maxRows(): number; - set maxRows(value: number); + set maxRows(value: NumberInput); get minRows(): number; - set minRows(value: number); - // (undocumented) - static ngAcceptInputType_enabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_maxRows: NumberInput; - // (undocumented) - static ngAcceptInputType_minRows: NumberInput; + set minRows(value: NumberInput); // (undocumented) ngAfterViewInit(): void; // (undocumented) diff --git a/tools/public_api_guard/cdk/tree.md b/tools/public_api_guard/cdk/tree.md index f264884d7790..7296e2e125c2 100644 --- a/tools/public_api_guard/cdk/tree.md +++ b/tools/public_api_guard/cdk/tree.md @@ -191,16 +191,14 @@ export class CdkTreeNodePadding implements OnDestroy { _indent: number; indentUnits: string; get level(): number; - set level(value: number); + set level(value: NumberInput); // (undocumented) _level: number; // (undocumented) - static ngAcceptInputType_level: NumberInput; - // (undocumented) ngOnDestroy(): void; _paddingIndent(): string | null; protected _setIndentInput(indent: number | string): void; - protected _setLevelInput(value: number): void; + protected _setLevelInput(value: NumberInput): void; // (undocumented) _setPadding(forceChange?: boolean): void; // (undocumented) @@ -212,10 +210,8 @@ export class CdkTreeNodePadding implements OnDestroy { // @public export class CdkTreeNodeToggle { constructor(_tree: CdkTree, _treeNode: CdkTreeNode); - // (undocumented) - static ngAcceptInputType_recursive: BooleanInput; get recursive(): boolean; - set recursive(value: boolean); + set recursive(value: BooleanInput); // (undocumented) protected _recursive: boolean; // (undocumented) diff --git a/tools/public_api_guard/material/autocomplete.md b/tools/public_api_guard/material/autocomplete.md index 58247525df07..6cc0d76a28c4 100644 --- a/tools/public_api_guard/material/autocomplete.md +++ b/tools/public_api_guard/material/autocomplete.md @@ -92,7 +92,7 @@ export abstract class _MatAutocompleteBase extends _MatAutocompleteMixinBase imp ariaLabel: string; ariaLabelledby: string; get autoActiveFirstOption(): boolean; - set autoActiveFirstOption(value: boolean); + set autoActiveFirstOption(value: BooleanInput); set classList(value: string | string[]); // (undocumented) _classList: { @@ -111,10 +111,6 @@ export abstract class _MatAutocompleteBase extends _MatAutocompleteMixinBase imp _isOpen: boolean; _keyManager: ActiveDescendantKeyManager<_MatOptionBase>; // (undocumented) - static ngAcceptInputType_autoActiveFirstOption: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnDestroy(): void; @@ -198,7 +194,7 @@ export abstract class _MatAutocompleteTriggerBase implements ControlValueAccesso autocomplete: _MatAutocompleteBase; autocompleteAttribute: string; get autocompleteDisabled(): boolean; - set autocompleteDisabled(value: boolean); + set autocompleteDisabled(value: BooleanInput); closePanel(): void; connectedTo: _MatAutocompleteOriginBase; // (undocumented) @@ -208,8 +204,6 @@ export abstract class _MatAutocompleteTriggerBase implements ControlValueAccesso // (undocumented) _handleKeydown(event: KeyboardEvent): void; // (undocumented) - static ngAcceptInputType_autocompleteDisabled: BooleanInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnChanges(changes: SimpleChanges): void; diff --git a/tools/public_api_guard/material/badge.md b/tools/public_api_guard/material/badge.md index bad1bf772b06..f6a9c14d7904 100644 --- a/tools/public_api_guard/material/badge.md +++ b/tools/public_api_guard/material/badge.md @@ -30,22 +30,16 @@ export class MatBadge extends _MatBadgeBase implements OnInit, OnDestroy, CanDis set description(newDescription: string); getBadgeElement(): HTMLElement | undefined; get hidden(): boolean; - set hidden(val: boolean); + set hidden(val: BooleanInput); _id: number; isAbove(): boolean; isAfter(): boolean; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_hidden: BooleanInput; - // (undocumented) - static ngAcceptInputType_overlap: BooleanInput; - // (undocumented) ngOnDestroy(): void; // (undocumented) ngOnInit(): void; get overlap(): boolean; - set overlap(val: boolean); + set overlap(val: BooleanInput); position: MatBadgePosition; size: MatBadgeSize; // (undocumented) diff --git a/tools/public_api_guard/material/button-toggle.md b/tools/public_api_guard/material/button-toggle.md index b2eef59e072c..6f011e8f5313 100644 --- a/tools/public_api_guard/material/button-toggle.md +++ b/tools/public_api_guard/material/button-toggle.md @@ -43,24 +43,14 @@ export class MatButtonToggle extends _MatButtonToggleBase implements OnInit, Aft buttonToggleGroup: MatButtonToggleGroup; readonly change: EventEmitter; get checked(): boolean; - set checked(value: boolean); + set checked(value: BooleanInput); get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); focus(options?: FocusOptions): void; id: string; _markForCheck(): void; name: string; // (undocumented) - static ngAcceptInputType_checked: BooleanInput; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_multiple: BooleanInput; - // (undocumented) - static ngAcceptInputType_vertical: BooleanInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnDestroy(): void; @@ -100,21 +90,15 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After readonly change: EventEmitter; _controlValueAccessorChangeFn: (value: any) => void; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); _emitChangeEvent(): void; _isPrechecked(toggle: MatButtonToggle): boolean; _isSelected(toggle: MatButtonToggle): boolean; get multiple(): boolean; - set multiple(value: boolean); + set multiple(value: BooleanInput); get name(): string; set name(value: string); // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_multiple: BooleanInput; - // (undocumented) - static ngAcceptInputType_vertical: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnInit(): void; @@ -131,7 +115,7 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After set value(newValue: any); readonly valueChange: EventEmitter; get vertical(): boolean; - set vertical(value: boolean); + set vertical(value: BooleanInput); writeValue(value: any): void; // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; diff --git a/tools/public_api_guard/material/button.md b/tools/public_api_guard/material/button.md index dc1c58c50c36..50b94137ce34 100644 --- a/tools/public_api_guard/material/button.md +++ b/tools/public_api_guard/material/button.md @@ -6,7 +6,6 @@ import { _AbstractConstructor } from '@angular/material/core'; import { AfterViewInit } from '@angular/core'; -import { BooleanInput } from '@angular/cdk/coercion'; import { CanColor } from '@angular/material/core'; import { CanDisable } from '@angular/material/core'; import { CanDisableRipple } from '@angular/material/core'; @@ -46,10 +45,6 @@ export class MatButton extends _MatButtonBase implements AfterViewInit, OnDestro _isRippleDisabled(): boolean; readonly isRoundButton: boolean; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnDestroy(): void; diff --git a/tools/public_api_guard/material/checkbox.md b/tools/public_api_guard/material/checkbox.md index aec9306393a2..5991d6833560 100644 --- a/tools/public_api_guard/material/checkbox.md +++ b/tools/public_api_guard/material/checkbox.md @@ -27,7 +27,6 @@ import * as i4 from '@angular/cdk/observers'; import { InjectionToken } from '@angular/core'; import { MatRipple } from '@angular/material/core'; import { NgZone } from '@angular/core'; -import { NumberInput } from '@angular/cdk/coercion'; import { OnDestroy } from '@angular/core'; import { Provider } from '@angular/core'; import { ThemePalette } from '@angular/material/core'; @@ -55,32 +54,22 @@ export class MatCheckbox extends _MatCheckboxBase implements ControlValueAccesso readonly change: EventEmitter; get checked(): boolean; set checked(value: boolean); - get disabled(): any; - set disabled(value: any); + get disabled(): boolean; + set disabled(value: BooleanInput); focus(origin?: FocusOrigin, options?: FocusOptions): void; // (undocumented) _getAriaChecked(): 'true' | 'false' | 'mixed'; id: string; get indeterminate(): boolean; - set indeterminate(value: boolean); + set indeterminate(value: BooleanInput); readonly indeterminateChange: EventEmitter; _inputElement: ElementRef; get inputId(): string; // (undocumented) - _isRippleDisabled(): any; + _isRippleDisabled(): boolean; labelPosition: 'before' | 'after'; name: string | null; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_indeterminate: BooleanInput; - // (undocumented) - static ngAcceptInputType_required: BooleanInput; - // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) ngAfterViewChecked(): void; // (undocumented) ngAfterViewInit(): void; @@ -96,7 +85,7 @@ export class MatCheckbox extends _MatCheckboxBase implements ControlValueAccesso // (undocumented) registerOnTouched(fn: any): void; get required(): boolean; - set required(value: boolean); + set required(value: BooleanInput); ripple: MatRipple; // (undocumented) setDisabledState(isDisabled: boolean): void; diff --git a/tools/public_api_guard/material/chips.md b/tools/public_api_guard/material/chips.md index 73fa7666a701..fb01b7b33663 100644 --- a/tools/public_api_guard/material/chips.md +++ b/tools/public_api_guard/material/chips.md @@ -30,7 +30,6 @@ import { MatFormFieldControl } from '@angular/material/form-field'; import { NgControl } from '@angular/forms'; import { NgForm } from '@angular/forms'; import { NgZone } from '@angular/core'; -import { NumberInput } from '@angular/cdk/coercion'; import { Observable } from 'rxjs'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; @@ -71,7 +70,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes deselect(): void; readonly destroyed: EventEmitter; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); // (undocumented) protected _disabled: boolean; focus(): void; @@ -79,23 +78,11 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes _handleKeydown(event: KeyboardEvent): void; _hasFocus: boolean; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_removable: BooleanInput; - // (undocumented) - static ngAcceptInputType_selectable: BooleanInput; - // (undocumented) - static ngAcceptInputType_selected: BooleanInput; - // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) ngOnDestroy(): void; readonly _onBlur: Subject; readonly _onFocus: Subject; get removable(): boolean; - set removable(value: boolean); + set removable(value: BooleanInput); // (undocumented) protected _removable: boolean; remove(): void; @@ -105,11 +92,11 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes get rippleDisabled(): boolean; select(): void; get selectable(): boolean; - set selectable(value: boolean); + set selectable(value: BooleanInput); // (undocumented) protected _selectable: boolean; get selected(): boolean; - set selected(value: boolean); + set selected(value: BooleanInput); // (undocumented) protected _selected: boolean; readonly selectionChange: EventEmitter; @@ -143,7 +130,7 @@ export interface MatChipEvent { export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, AfterContentInit { constructor(_elementRef: ElementRef, _defaultOptions: MatChipsDefaultOptions); get addOnBlur(): boolean; - set addOnBlur(value: boolean); + set addOnBlur(value: BooleanInput); // (undocumented) _addOnBlur: boolean; _blur(): void; @@ -153,7 +140,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, A _chipList: MatChipList; clear(): void; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); // (undocumented) protected _elementRef: ElementRef; _emitChipEnd(event?: KeyboardEvent): void; @@ -167,10 +154,6 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, A _keydown(event?: KeyboardEvent): void; _keyup(event: KeyboardEvent): void; // (undocumented) - static ngAcceptInputType_addOnBlur: BooleanInput; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnChanges(): void; @@ -212,7 +195,7 @@ export class MatChipList extends _MatChipListBase implements MatFormFieldControl set compareWith(fn: (o1: any, o2: any) => boolean); readonly controlType: string; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); // (undocumented) protected _disabled: boolean; // (undocumented) @@ -227,15 +210,7 @@ export class MatChipList extends _MatChipListBase implements MatFormFieldControl _keyManager: FocusKeyManager; _markAsTouched(): void; get multiple(): boolean; - set multiple(value: boolean); - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_multiple: BooleanInput; - // (undocumented) - static ngAcceptInputType_required: BooleanInput; - // (undocumented) - static ngAcceptInputType_selectable: BooleanInput; + set multiple(value: BooleanInput); // (undocumented) ngAfterContentInit(): void; // (undocumented) @@ -257,12 +232,12 @@ export class MatChipList extends _MatChipListBase implements MatFormFieldControl // (undocumented) registerOnTouched(fn: () => void): void; get required(): boolean; - set required(value: boolean); + set required(value: BooleanInput); // (undocumented) protected _required: boolean | undefined; get role(): string | null; get selectable(): boolean; - set selectable(value: boolean); + set selectable(value: BooleanInput); // (undocumented) protected _selectable: boolean; get selected(): MatChip[] | MatChip; diff --git a/tools/public_api_guard/material/core.md b/tools/public_api_guard/material/core.md index f44a37676dac..c081db0d6d31 100644 --- a/tools/public_api_guard/material/core.md +++ b/tools/public_api_guard/material/core.md @@ -260,8 +260,6 @@ export class _MatOptgroupBase extends _MatOptgroupMixinBase implements CanDisabl label: string; _labelId: string; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration<_MatOptgroupBase, never, never, { "label": "label"; }, {}, never>; // (undocumented) static ɵfac: i0.ɵɵFactoryDeclaration<_MatOptgroupBase, [{ optional: true; }]>; @@ -281,9 +279,9 @@ export class _MatOptionBase implements FocusableOption, AfterViewChecked, OnDest constructor(_element: ElementRef, _changeDetectorRef: ChangeDetectorRef, _parent: MatOptionParentComponent, group: _MatOptgroupBase); get active(): boolean; deselect(): void; - get disabled(): any; - set disabled(value: any); - get disableRipple(): boolean | undefined; + get disabled(): boolean; + set disabled(value: BooleanInput); + get disableRipple(): boolean; focus(_origin?: FocusOrigin, options?: FocusOptions_2): void; _getAriaSelected(): boolean | null; _getHostElement(): HTMLElement; @@ -295,8 +293,6 @@ export class _MatOptionBase implements FocusableOption, AfterViewChecked, OnDest id: string; get multiple(): boolean | undefined; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngAfterViewChecked(): void; // (undocumented) ngOnDestroy(): void; diff --git a/tools/public_api_guard/material/datepicker.md b/tools/public_api_guard/material/datepicker.md index bc0afe8e697e..c8fb85e4fca7 100644 --- a/tools/public_api_guard/material/datepicker.md +++ b/tools/public_api_guard/material/datepicker.md @@ -359,7 +359,7 @@ abstract class MatDatepickerBase, S, D = Extra dateClass: MatCalendarCellClassFunction; datepickerInput: C; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); protected _forwardContentValues(instance: MatDatepickerContent): void; // (undocumented) _getDateFilter(): DateFilterFn; @@ -368,20 +368,12 @@ abstract class MatDatepickerBase, S, D = Extra id: string; readonly monthSelected: EventEmitter; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_opened: BooleanInput; - // (undocumented) - static ngAcceptInputType_restoreFocus: BooleanInput; - // (undocumented) - static ngAcceptInputType_touchUi: BooleanInput; - // (undocumented) ngOnChanges(changes: SimpleChanges): void; // (undocumented) ngOnDestroy(): void; open(): void; get opened(): boolean; - set opened(value: boolean); + set opened(value: BooleanInput); readonly openedStream: EventEmitter; get panelClass(): string | string[]; set panelClass(value: string | string[]); @@ -389,7 +381,7 @@ abstract class MatDatepickerBase, S, D = Extra registerInput(input: C): MatDateSelectionModel; removeActions(portal: TemplatePortal): void; get restoreFocus(): boolean; - set restoreFocus(value: boolean); + set restoreFocus(value: BooleanInput); select(date: D): void; _selectMonth(normalizedMonth: D): void; _selectYear(normalizedYear: D): void; @@ -398,7 +390,7 @@ abstract class MatDatepickerBase, S, D = Extra startView: 'month' | 'year' | 'multi-year'; readonly stateChanges: Subject; get touchUi(): boolean; - set touchUi(value: boolean); + set touchUi(value: BooleanInput); readonly viewChanged: EventEmitter; _viewChanged(view: MatCalendarView): void; xPosition: DatepickerDropdownPositionX; @@ -573,13 +565,11 @@ export class MatDatepickerToggle implements AfterContentInit, OnChanges, OnDe _customIcon: MatDatepickerToggleIcon; datepicker: MatDatepickerPanel, D>; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); disableRipple: boolean; // (undocumented) _intl: MatDatepickerIntl; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnChanges(changes: SimpleChanges): void; @@ -612,7 +602,7 @@ export class MatDateRangeInput implements MatFormFieldControl>, get dateFilter(): DateFilterFn; set dateFilter(value: DateFilterFn); get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); get empty(): boolean; // (undocumented) _endInput: MatEndDate; @@ -633,10 +623,6 @@ export class MatDateRangeInput implements MatFormFieldControl>, get min(): D | null; set min(value: D | null); // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_required: BooleanInput; - // (undocumented) ngAfterContentInit(): void; ngControl: NgControl | null; // (undocumented) @@ -649,7 +635,7 @@ export class MatDateRangeInput implements MatFormFieldControl>, get rangePicker(): MatDatepickerPanel, DateRange, D>; set rangePicker(rangePicker: MatDatepickerPanel, DateRange, D>); get required(): boolean; - set required(value: boolean); + set required(value: BooleanInput); separator: string; setDescribedByIds(ids: string[]): void; _shouldHidePlaceholders(): boolean; diff --git a/tools/public_api_guard/material/divider.md b/tools/public_api_guard/material/divider.md index da5649fec26c..df4ef44cf8d5 100644 --- a/tools/public_api_guard/material/divider.md +++ b/tools/public_api_guard/material/divider.md @@ -11,13 +11,9 @@ import * as i2 from '@angular/material/core'; // @public (undocumented) export class MatDivider { get inset(): boolean; - set inset(value: boolean); - // (undocumented) - static ngAcceptInputType_inset: BooleanInput; - // (undocumented) - static ngAcceptInputType_vertical: BooleanInput; + set inset(value: BooleanInput); get vertical(): boolean; - set vertical(value: boolean); + set vertical(value: BooleanInput); // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) diff --git a/tools/public_api_guard/material/expansion.md b/tools/public_api_guard/material/expansion.md index b6bfc69a8c95..8a033ebf00ad 100644 --- a/tools/public_api_guard/material/expansion.md +++ b/tools/public_api_guard/material/expansion.md @@ -26,7 +26,6 @@ import * as i6 from '@angular/material/core'; import * as i7 from '@angular/cdk/accordion'; import * as i8 from '@angular/cdk/portal'; import { InjectionToken } from '@angular/core'; -import { NumberInput } from '@angular/cdk/coercion'; import { OnChanges } from '@angular/core'; import { OnDestroy } from '@angular/core'; import { QueryList } from '@angular/core'; @@ -54,9 +53,7 @@ export class MatAccordion extends CdkAccordion implements MatAccordionBase, Afte _handleHeaderKeydown(event: KeyboardEvent): void; _headers: QueryList; get hideToggle(): boolean; - set hideToggle(show: boolean); - // (undocumented) - static ngAcceptInputType_hideToggle: BooleanInput; + set hideToggle(show: BooleanInput); // (undocumented) ngAfterContentInit(): void; // (undocumented) @@ -115,12 +112,10 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI _hasSpacing(): boolean; _headerId: string; get hideToggle(): boolean; - set hideToggle(value: boolean); + set hideToggle(value: BooleanInput); readonly _inputChanges: Subject; _lazyContent: MatExpansionPanelContent; // (undocumented) - static ngAcceptInputType_hideToggle: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnChanges(changes: SimpleChanges): void; @@ -187,8 +182,6 @@ export class MatExpansionPanelHeader extends _MatExpansionPanelHeaderMixinBase i _isExpanded(): boolean; _keydown(event: KeyboardEvent): void; // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnDestroy(): void; diff --git a/tools/public_api_guard/material/form-field.md b/tools/public_api_guard/material/form-field.md index 23c7f37adcc1..4e3f045a0c4d 100644 --- a/tools/public_api_guard/material/form-field.md +++ b/tools/public_api_guard/material/form-field.md @@ -103,7 +103,7 @@ export class MatFormField extends _MatFormFieldBase implements AfterContentInit, // (undocumented) _hideControlPlaceholder(): boolean; get hideRequiredMarker(): boolean; - set hideRequiredMarker(value: boolean); + set hideRequiredMarker(value: BooleanInput); // (undocumented) _hintChildren: QueryList; get hintLabel(): string; @@ -119,8 +119,6 @@ export class MatFormField extends _MatFormFieldBase implements AfterContentInit, // (undocumented) readonly _labelId: string; // (undocumented) - static ngAcceptInputType_hideRequiredMarker: BooleanInput; - // (undocumented) ngAfterContentChecked(): void; // (undocumented) ngAfterContentInit(): void; diff --git a/tools/public_api_guard/material/grid-list.md b/tools/public_api_guard/material/grid-list.md index 99d758125fdb..a84ac5f46863 100644 --- a/tools/public_api_guard/material/grid-list.md +++ b/tools/public_api_guard/material/grid-list.md @@ -27,11 +27,9 @@ export class MatGridAvatarCssMatStyler { export class MatGridList implements MatGridListBase, OnInit, AfterContentChecked, TileStyleTarget { constructor(_element: ElementRef, _dir: Directionality); get cols(): number; - set cols(value: number); + set cols(value: NumberInput); get gutterSize(): string; set gutterSize(value: string); - // (undocumented) - static ngAcceptInputType_cols: NumberInput; ngAfterContentChecked(): void; // (undocumented) ngOnInit(): void; @@ -59,17 +57,13 @@ export class MatGridListModule { export class MatGridTile { constructor(_element: ElementRef, _gridList?: MatGridListBase | undefined); get colspan(): number; - set colspan(value: number); + set colspan(value: NumberInput); // (undocumented) _colspan: number; // (undocumented) _gridList?: MatGridListBase | undefined; - // (undocumented) - static ngAcceptInputType_colspan: NumberInput; - // (undocumented) - static ngAcceptInputType_rowspan: NumberInput; get rowspan(): number; - set rowspan(value: number); + set rowspan(value: NumberInput); // (undocumented) _rowspan: number; _setStyle(property: string, value: any): void; diff --git a/tools/public_api_guard/material/icon.md b/tools/public_api_guard/material/icon.md index 9f3b46bf789f..d38d4d2603a1 100644 --- a/tools/public_api_guard/material/icon.md +++ b/tools/public_api_guard/material/icon.md @@ -68,9 +68,7 @@ export class MatIcon extends _MatIconBase implements OnInit, AfterViewChecked, C get fontSet(): string; set fontSet(value: string); get inline(): boolean; - set inline(inline: boolean); - // (undocumented) - static ngAcceptInputType_inline: BooleanInput; + set inline(inline: BooleanInput); // (undocumented) ngAfterViewChecked(): void; // (undocumented) diff --git a/tools/public_api_guard/material/input.md b/tools/public_api_guard/material/input.md index 9a6d511c6eb8..7f3897f19420 100644 --- a/tools/public_api_guard/material/input.md +++ b/tools/public_api_guard/material/input.md @@ -44,7 +44,7 @@ export class MatInput extends _MatInputBase implements MatFormFieldControl, controlType: string; protected _dirtyCheckNativeValue(): void; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); // (undocumented) protected _disabled: boolean; // (undocumented) @@ -68,14 +68,6 @@ export class MatInput extends _MatInputBase implements MatFormFieldControl, // (undocumented) protected _neverEmptyInputTypes: string[]; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_readonly: BooleanInput; - // (undocumented) - static ngAcceptInputType_required: BooleanInput; - // (undocumented) - static ngAcceptInputType_value: any; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngDoCheck(): void; @@ -92,9 +84,9 @@ export class MatInput extends _MatInputBase implements MatFormFieldControl, // (undocumented) protected _previousNativeValue: any; get readonly(): boolean; - set readonly(value: boolean); + set readonly(value: BooleanInput); get required(): boolean; - set required(value: boolean); + set required(value: BooleanInput); // (undocumented) protected _required: boolean | undefined; setDescribedByIds(ids: string[]): void; @@ -109,7 +101,7 @@ export class MatInput extends _MatInputBase implements MatFormFieldControl, userAriaDescribedBy: string; protected _validateType(): void; get value(): string; - set value(value: string); + set value(value: any); // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) diff --git a/tools/public_api_guard/material/list.md b/tools/public_api_guard/material/list.md index 0cdc0a53b757..7d663f341721 100644 --- a/tools/public_api_guard/material/list.md +++ b/tools/public_api_guard/material/list.md @@ -47,10 +47,6 @@ export class MatList extends _MatListBase implements CanDisable, CanDisableRippl // (undocumented) _getListType(): 'list' | 'action-list' | null; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) ngOnChanges(): void; // (undocumented) ngOnDestroy(): void; @@ -83,7 +79,7 @@ export class MatListItem extends _MatListItemMixinBase implements AfterContentIn // (undocumented) _avatar: MatListAvatarCssMatStyler; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); _getHostElement(): HTMLElement; // (undocumented) _icon: MatListIconCssMatStyler; @@ -91,10 +87,6 @@ export class MatListItem extends _MatListItemMixinBase implements AfterContentIn // (undocumented) _lines: QueryList; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnDestroy(): void; @@ -123,8 +115,8 @@ export class MatListOption extends _MatListOptionBase implements AfterContentIni checkboxPosition: MatListOptionCheckboxPosition; get color(): ThemePalette; set color(newValue: ThemePalette); - get disabled(): any; - set disabled(value: any); + get disabled(): boolean; + set disabled(value: BooleanInput); focus(): void; _getHostElement(): HTMLElement; getLabel(): any; @@ -136,24 +128,18 @@ export class MatListOption extends _MatListOptionBase implements AfterContentIni _handleFocus(): void; // (undocumented) _icon: MatListIconCssMatStyler; - _isRippleDisabled(): any; + _isRippleDisabled(): boolean; // (undocumented) _lines: QueryList; _markForCheck(): void; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_selected: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnDestroy(): void; // (undocumented) ngOnInit(): void; get selected(): boolean; - set selected(value: boolean); + set selected(value: BooleanInput); readonly selectedChange: EventEmitter; selectionList: MatSelectionList; _setSelected(selected: boolean): boolean; @@ -180,10 +166,6 @@ export class MatListSubheaderCssMatStyler { // @public (undocumented) export class MatNavList extends _MatListBase implements CanDisable, CanDisableRipple, OnChanges, OnDestroy { - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; // (undocumented) ngOnChanges(): void; // (undocumented) @@ -202,19 +184,13 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl compareWith: (o1: any, o2: any) => boolean; deselectAll(): MatListOption[]; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); _emitChangeEvent(options: MatListOption[]): void; focus(options?: FocusOptions): void; _keydown(event: KeyboardEvent): void; _keyManager: FocusKeyManager; get multiple(): boolean; - set multiple(value: boolean); - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_multiple: BooleanInput; + set multiple(value: BooleanInput); // (undocumented) ngAfterContentInit(): void; // (undocumented) diff --git a/tools/public_api_guard/material/menu.md b/tools/public_api_guard/material/menu.md index 31286c5d44c9..1eccbea708cc 100644 --- a/tools/public_api_guard/material/menu.md +++ b/tools/public_api_guard/material/menu.md @@ -116,17 +116,13 @@ export class _MatMenuBase implements AfterContentInit, MatMenuPanel focusFirstItem(origin?: FocusOrigin): void; _handleKeydown(event: KeyboardEvent): void; get hasBackdrop(): boolean | undefined; - set hasBackdrop(value: boolean | undefined); + set hasBackdrop(value: BooleanInput); _hovered(): Observable; _isAnimating: boolean; // @deprecated items: QueryList; lazyContent: MatMenuContent; // (undocumented) - static ngAcceptInputType_hasBackdrop: BooleanInput; - // (undocumented) - static ngAcceptInputType_overlapTrigger: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnDestroy(): void; @@ -136,7 +132,7 @@ export class _MatMenuBase implements AfterContentInit, MatMenuPanel // (undocumented) _onAnimationStart(event: AnimationEvent_2): void; get overlapTrigger(): boolean; - set overlapTrigger(value: boolean); + set overlapTrigger(value: BooleanInput); overlayPanelClass: string | string[]; _panelAnimationState: 'void' | 'enter'; set panelClass(classes: string); @@ -208,10 +204,6 @@ export class MatMenuItem extends _MatMenuItemBase implements FocusableOption, Ca _highlighted: boolean; readonly _hovered: Subject; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnDestroy(): void; diff --git a/tools/public_api_guard/material/paginator.md b/tools/public_api_guard/material/paginator.md index dc4c11c3c4e0..ae8499d5d8ac 100644 --- a/tools/public_api_guard/material/paginator.md +++ b/tools/public_api_guard/material/paginator.md @@ -65,41 +65,29 @@ export abstract class _MatPaginatorBase; get pageIndex(): number; - set pageIndex(value: number); + set pageIndex(value: NumberInput); get pageSize(): number; - set pageSize(value: number); + set pageSize(value: NumberInput); get pageSizeOptions(): number[]; set pageSizeOptions(value: number[]); _previousButtonsDisabled(): boolean; previousPage(): void; get showFirstLastButtons(): boolean; - set showFirstLastButtons(value: boolean); + set showFirstLastButtons(value: BooleanInput); // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration<_MatPaginatorBase, never, never, { "color": "color"; "pageIndex": "pageIndex"; "length": "length"; "pageSize": "pageSize"; "pageSizeOptions": "pageSizeOptions"; "hidePageSize": "hidePageSize"; "showFirstLastButtons": "showFirstLastButtons"; }, { "page": "page"; }, never>; // (undocumented) diff --git a/tools/public_api_guard/material/progress-bar.md b/tools/public_api_guard/material/progress-bar.md index 20b5cd3e2071..2d8d805e280b 100644 --- a/tools/public_api_guard/material/progress-bar.md +++ b/tools/public_api_guard/material/progress-bar.md @@ -43,8 +43,6 @@ export class MatProgressBar extends _MatProgressBarBase implements CanColor, Aft _isNoopAnimation: boolean; mode: ProgressBarMode; // (undocumented) - static ngAcceptInputType_value: NumberInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnDestroy(): void; @@ -56,7 +54,7 @@ export class MatProgressBar extends _MatProgressBarBase implements CanColor, Aft progressbarId: string; _rectangleFillValue: string; get value(): number; - set value(v: number); + set value(v: NumberInput); // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) diff --git a/tools/public_api_guard/material/progress-spinner.md b/tools/public_api_guard/material/progress-spinner.md index 327e269e9e9f..3af5b8ca941b 100644 --- a/tools/public_api_guard/material/progress-spinner.md +++ b/tools/public_api_guard/material/progress-spinner.md @@ -27,7 +27,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements OnIni constructor(elementRef: ElementRef, _platform: Platform, _document: any, animationMode: string, defaults?: MatProgressSpinnerDefaultOptions); get diameter(): number; - set diameter(size: number); + set diameter(size: NumberInput); _getCircleRadius(): number; _getCircleStrokeWidth(): number; _getStrokeCircumference(): number; @@ -35,19 +35,13 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements OnIni _getViewBox(): string; mode: ProgressSpinnerMode; // (undocumented) - static ngAcceptInputType_diameter: NumberInput; - // (undocumented) - static ngAcceptInputType_strokeWidth: NumberInput; - // (undocumented) - static ngAcceptInputType_value: NumberInput; - // (undocumented) ngOnInit(): void; _noopAnimations: boolean; _spinnerAnimationLabel: string; get strokeWidth(): number; - set strokeWidth(value: number); + set strokeWidth(value: NumberInput); get value(): number; - set value(newValue: number); + set value(newValue: NumberInput); // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) diff --git a/tools/public_api_guard/material/radio.md b/tools/public_api_guard/material/radio.md index 1dff11e3e984..c727b1ae98af 100644 --- a/tools/public_api_guard/material/radio.md +++ b/tools/public_api_guard/material/radio.md @@ -20,7 +20,6 @@ import { HasTabIndex } from '@angular/material/core'; import * as i0 from '@angular/core'; import * as i2 from '@angular/material/core'; import { InjectionToken } from '@angular/core'; -import { NumberInput } from '@angular/cdk/coercion'; import { OnDestroy } from '@angular/core'; import { OnInit } from '@angular/core'; import { QueryList } from '@angular/core'; @@ -58,11 +57,11 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple // (undocumented) protected _changeDetector: ChangeDetectorRef; get checked(): boolean; - set checked(value: boolean); + set checked(value: BooleanInput); get color(): ThemePalette; set color(newValue: ThemePalette); get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); focus(options?: FocusOptions, origin?: FocusOrigin): void; id: string; _inputElement: ElementRef; @@ -74,16 +73,6 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple _markForCheck(): void; name: string; // (undocumented) - static ngAcceptInputType_checked: BooleanInput; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_required: BooleanInput; - // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnDestroy(): void; @@ -95,7 +84,7 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple _onInputInteraction(event: Event): void; radioGroup: _MatRadioGroupBase<_MatRadioButtonBase>; get required(): boolean; - set required(value: boolean); + set required(value: BooleanInput); protected _setDisabled(value: boolean): void; get value(): any; set value(value: any); @@ -139,7 +128,7 @@ export abstract class _MatRadioGroupBase implemen color: ThemePalette; _controlValueAccessorChangeFn: (value: any) => void; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); _emitChangeEvent(): void; get labelPosition(): 'before' | 'after'; set labelPosition(v: 'before' | 'after'); @@ -147,17 +136,13 @@ export abstract class _MatRadioGroupBase implemen _markRadiosForCheck(): void; get name(): string; set name(value: string); - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_required: BooleanInput; ngAfterContentInit(): void; onTouched: () => any; abstract _radios: QueryList; registerOnChange(fn: (value: any) => void): void; registerOnTouched(fn: any): void; get required(): boolean; - set required(value: boolean); + set required(value: BooleanInput); get selected(): T | null; set selected(selected: T | null); setDisabledState(isDisabled: boolean): void; diff --git a/tools/public_api_guard/material/select.md b/tools/public_api_guard/material/select.md index 16493d054582..a21247cc2fc1 100644 --- a/tools/public_api_guard/material/select.md +++ b/tools/public_api_guard/material/select.md @@ -128,7 +128,7 @@ export abstract class _MatSelectBase extends _MatSelectMixinBase implements A abstract customTrigger: {}; protected readonly _destroy: Subject; get disableOptionCentering(): boolean; - set disableOptionCentering(value: boolean); + set disableOptionCentering(value: BooleanInput); get empty(): boolean; errorStateMatcher: ErrorStateMatcher; focus(options?: FocusOptions): void; @@ -143,21 +143,7 @@ export abstract class _MatSelectBase extends _MatSelectMixinBase implements A _isRtl(): boolean; _keyManager: ActiveDescendantKeyManager; get multiple(): boolean; - set multiple(value: boolean); - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableOptionCentering: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_multiple: BooleanInput; - // (undocumented) - static ngAcceptInputType_required: BooleanInput; - // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) - static ngAcceptInputType_typeaheadDebounceInterval: NumberInput; + set multiple(value: BooleanInput); // (undocumented) ngAfterContentInit(): void; // (undocumented) @@ -202,7 +188,7 @@ export abstract class _MatSelectBase extends _MatSelectMixinBase implements A registerOnChange(fn: (value: any) => void): void; registerOnTouched(fn: () => {}): void; get required(): boolean; - set required(value: boolean); + set required(value: BooleanInput); protected abstract _scrollOptionIntoView(index: number): void; _scrollStrategy: ScrollStrategy; get selected(): MatOption | MatOption[]; @@ -216,7 +202,7 @@ export abstract class _MatSelectBase extends _MatSelectMixinBase implements A trigger: ElementRef; get triggerValue(): string; get typeaheadDebounceInterval(): number; - set typeaheadDebounceInterval(value: number); + set typeaheadDebounceInterval(value: NumberInput); get value(): any; set value(newValue: any); readonly valueChange: EventEmitter; diff --git a/tools/public_api_guard/material/sidenav.md b/tools/public_api_guard/material/sidenav.md index 29e5b2a47cf2..85762e2a76ef 100644 --- a/tools/public_api_guard/material/sidenav.md +++ b/tools/public_api_guard/material/sidenav.md @@ -54,7 +54,7 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr readonly _animationStarted: Subject; _animationState: 'open-instant' | 'open' | 'void'; get autoFocus(): AutoFocusTarget | string | boolean; - set autoFocus(value: AutoFocusTarget | string | boolean); + set autoFocus(value: AutoFocusTarget | string | BooleanInput); close(): Promise; readonly closedStart: Observable; readonly _closedStream: Observable; @@ -62,19 +62,13 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr // (undocumented) _container?: MatDrawerContainer | undefined; get disableClose(): boolean; - set disableClose(value: boolean); + set disableClose(value: BooleanInput); // (undocumented) _getWidth(): number; get mode(): MatDrawerMode; set mode(value: MatDrawerMode); readonly _modeChanged: Subject; // (undocumented) - static ngAcceptInputType_autoFocus: AutoFocusTarget | string | BooleanInput; - // (undocumented) - static ngAcceptInputType_disableClose: BooleanInput; - // (undocumented) - static ngAcceptInputType_opened: BooleanInput; - // (undocumented) ngAfterContentChecked(): void; // (undocumented) ngAfterContentInit(): void; @@ -83,7 +77,7 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr readonly onPositionChanged: EventEmitter; open(openedVia?: FocusOrigin): Promise; get opened(): boolean; - set opened(value: boolean); + set opened(value: BooleanInput); readonly openedChange: EventEmitter; readonly openedStart: Observable; readonly _openedStream: Observable; @@ -106,7 +100,7 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy constructor(_dir: Directionality, _element: ElementRef, _ngZone: NgZone, _changeDetectorRef: ChangeDetectorRef, viewportRuler: ViewportRuler, defaultAutosize?: boolean, _animationMode?: string | undefined); _allDrawers: QueryList; get autosize(): boolean; - set autosize(value: boolean); + set autosize(value: BooleanInput); readonly backdropClick: EventEmitter; // (undocumented) _backdropOverride: boolean | null; @@ -126,15 +120,11 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy }; _drawers: QueryList; get end(): MatDrawer | null; - get hasBackdrop(): any; - set hasBackdrop(value: any); + get hasBackdrop(): boolean; + set hasBackdrop(value: BooleanInput); // (undocumented) _isShowingBackdrop(): boolean; // (undocumented) - static ngAcceptInputType_autosize: BooleanInput; - // (undocumented) - static ngAcceptInputType_hasBackdrop: BooleanInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngDoCheck(): void; @@ -176,17 +166,11 @@ export type MatDrawerToggleResult = 'open' | 'close'; // @public (undocumented) export class MatSidenav extends MatDrawer { get fixedBottomGap(): number; - set fixedBottomGap(value: number); + set fixedBottomGap(value: NumberInput); get fixedInViewport(): boolean; - set fixedInViewport(value: boolean); + set fixedInViewport(value: BooleanInput); get fixedTopGap(): number; - set fixedTopGap(value: number); - // (undocumented) - static ngAcceptInputType_fixedBottomGap: NumberInput; - // (undocumented) - static ngAcceptInputType_fixedInViewport: BooleanInput; - // (undocumented) - static ngAcceptInputType_fixedTopGap: NumberInput; + set fixedTopGap(value: NumberInput); // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) diff --git a/tools/public_api_guard/material/slide-toggle.md b/tools/public_api_guard/material/slide-toggle.md index 84c00f99d096..8e95833bdc5d 100644 --- a/tools/public_api_guard/material/slide-toggle.md +++ b/tools/public_api_guard/material/slide-toggle.md @@ -23,7 +23,6 @@ import * as i0 from '@angular/core'; import * as i3 from '@angular/material/core'; import * as i4 from '@angular/cdk/observers'; import { InjectionToken } from '@angular/core'; -import { NumberInput } from '@angular/cdk/coercion'; import { OnDestroy } from '@angular/core'; import { Provider } from '@angular/core'; import { ThemePalette } from '@angular/material/core'; @@ -45,7 +44,7 @@ export class MatSlideToggle extends _MatSlideToggleBase implements OnDestroy, Af ariaLabelledby: string | null; readonly change: EventEmitter; get checked(): boolean; - set checked(value: boolean); + set checked(value: BooleanInput); // (undocumented) defaults: MatSlideToggleDefaultOptions; focus(options?: FocusOptions, origin?: FocusOrigin): void; @@ -55,16 +54,6 @@ export class MatSlideToggle extends _MatSlideToggleBase implements OnDestroy, Af labelPosition: 'before' | 'after'; name: string | null; // (undocumented) - static ngAcceptInputType_checked: BooleanInput; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_required: BooleanInput; - // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) ngAfterContentInit(): void; // (undocumented) ngOnDestroy(): void; @@ -75,7 +64,7 @@ export class MatSlideToggle extends _MatSlideToggleBase implements OnDestroy, Af registerOnChange(fn: any): void; registerOnTouched(fn: any): void; get required(): boolean; - set required(value: boolean); + set required(value: BooleanInput); setDisabledState(isDisabled: boolean): void; _thumbBarEl: ElementRef; _thumbEl: ElementRef; diff --git a/tools/public_api_guard/material/slider.md b/tools/public_api_guard/material/slider.md index 308d39aebb61..d9e6a7f53336 100644 --- a/tools/public_api_guard/material/slider.md +++ b/tools/public_api_guard/material/slider.md @@ -57,34 +57,14 @@ export class MatSlider extends _MatSliderBase implements ControlValueAccessor, O }; readonly input: EventEmitter; get invert(): boolean; - set invert(value: boolean); + set invert(value: BooleanInput); _isActive: boolean; _isMinValue(): boolean; _isSliding: 'keyboard' | 'pointer' | null; get max(): number; - set max(v: number); + set max(v: NumberInput); get min(): number; - set min(v: number); - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_invert: BooleanInput; - // (undocumented) - static ngAcceptInputType_max: NumberInput; - // (undocumented) - static ngAcceptInputType_min: NumberInput; - // (undocumented) - static ngAcceptInputType_step: NumberInput; - // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) - static ngAcceptInputType_thumbLabel: BooleanInput; - // (undocumented) - static ngAcceptInputType_tickInterval: NumberInput; - // (undocumented) - static ngAcceptInputType_value: NumberInput; - // (undocumented) - static ngAcceptInputType_vertical: BooleanInput; + set min(v: NumberInput); // (undocumented) ngAfterViewInit(): void; // (undocumented) @@ -107,17 +87,17 @@ export class MatSlider extends _MatSliderBase implements ControlValueAccessor, O _shouldInvertAxis(): boolean; _shouldInvertMouseCoords(): boolean; get step(): number; - set step(v: number); + set step(v: NumberInput); get thumbLabel(): boolean; - set thumbLabel(value: boolean); + set thumbLabel(value: BooleanInput); get tickInterval(): 'auto' | number; - set tickInterval(value: 'auto' | number); + set tickInterval(value: 'auto' | NumberInput); get value(): number; - set value(v: number); + set value(v: NumberInput); readonly valueChange: EventEmitter; valueText: string; get vertical(): boolean; - set vertical(value: boolean); + set vertical(value: BooleanInput); writeValue(value: any): void; // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; diff --git a/tools/public_api_guard/material/sort.md b/tools/public_api_guard/material/sort.md index 5cf39bcdc7ed..5b419bc4e475 100644 --- a/tools/public_api_guard/material/sort.md +++ b/tools/public_api_guard/material/sort.md @@ -58,13 +58,9 @@ export class MatSort extends _MatSortBase implements CanDisable, HasInitialized, get direction(): SortDirection; set direction(direction: SortDirection); get disableClear(): boolean; - set disableClear(v: boolean); + set disableClear(v: BooleanInput); getNextSortDirection(sortable: MatSortable): SortDirection; // (undocumented) - static ngAcceptInputType_disableClear: BooleanInput; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngOnChanges(): void; // (undocumented) ngOnDestroy(): void; @@ -114,7 +110,7 @@ export class MatSortHeader extends _MatSortHeaderBase implements CanDisable, Mat // (undocumented) _columnDef: MatSortHeaderColumnDef; get disableClear(): boolean; - set disableClear(v: boolean); + set disableClear(v: BooleanInput); _disableViewStateAnimation: boolean; _getAriaSortAttribute(): "none" | "ascending" | "descending"; _getArrowDirectionState(): string; @@ -130,10 +126,6 @@ export class MatSortHeader extends _MatSortHeaderBase implements CanDisable, Mat _isDisabled(): boolean; _isSorted(): boolean; // (undocumented) - static ngAcceptInputType_disableClear: BooleanInput; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnDestroy(): void; diff --git a/tools/public_api_guard/material/tabs.md b/tools/public_api_guard/material/tabs.md index 7e0b17546247..d83ff2f99f45 100644 --- a/tools/public_api_guard/material/tabs.md +++ b/tools/public_api_guard/material/tabs.md @@ -108,8 +108,6 @@ export class MatTab extends _MatTabBase implements OnInit, CanDisable, OnChanges _implicitContent: TemplateRef; isActive: boolean; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) ngOnChanges(changes: SimpleChanges): void; // (undocumented) ngOnDestroy(): void; @@ -223,7 +221,7 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements abstract _allTabs: QueryList; readonly animationDone: EventEmitter; get animationDuration(): string; - set animationDuration(value: string); + set animationDuration(value: NumberInput); // (undocumented) _animationMode?: string | undefined; get backgroundColor(): ThemePalette; @@ -231,10 +229,10 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements // (undocumented) protected _changeDetectorRef: ChangeDetectorRef; get contentTabIndex(): number | null; - set contentTabIndex(value: number | null); + set contentTabIndex(value: NumberInput); disablePagination: boolean; get dynamicHeight(): boolean; - set dynamicHeight(value: boolean); + set dynamicHeight(value: BooleanInput); readonly focusChange: EventEmitter; // (undocumented) _focusChanged(index: number): void; @@ -244,16 +242,6 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements _getTabLabelId(i: number): string; _handleClick(tab: MatTab, tabHeader: MatTabGroupBaseHeader, index: number): void; headerPosition: MatTabHeaderPosition; - // (undocumented) - static ngAcceptInputType_animationDuration: NumberInput; - // (undocumented) - static ngAcceptInputType_contentTabIndex: NumberInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_dynamicHeight: BooleanInput; - // (undocumented) - static ngAcceptInputType_selectedIndex: NumberInput; ngAfterContentChecked(): void; // (undocumented) ngAfterContentInit(): void; @@ -262,7 +250,7 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements realignInkBar(): void; _removeTabBodyWrapperHeight(): void; get selectedIndex(): number | null; - set selectedIndex(value: number | null); + set selectedIndex(value: NumberInput); readonly selectedIndexChange: EventEmitter; readonly selectedTabChange: EventEmitter; _setTabBodyWrapperHeight(tabHeight: number): void; @@ -288,8 +276,6 @@ export class MatTabHeader extends _MatTabHeaderBase { // (undocumented) _nextPaginator: ElementRef; // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) _previousPaginator: ElementRef; // (undocumented) _tabList: ElementRef; @@ -306,8 +292,8 @@ export class MatTabHeader extends _MatTabHeaderBase { // @public export abstract class _MatTabHeaderBase extends MatPaginatedTabHeader implements AfterContentChecked, AfterContentInit, AfterViewInit, OnDestroy { constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef, viewportRuler: ViewportRuler, dir: Directionality, ngZone: NgZone, platform: Platform, animationMode?: string); - get disableRipple(): any; - set disableRipple(value: any); + get disableRipple(): boolean; + set disableRipple(value: BooleanInput); // (undocumented) protected _itemSelected(event: KeyboardEvent): void; // (undocumented) @@ -341,8 +327,6 @@ export class MatTabLabelWrapper extends _MatTabLabelWrapperBase implements CanDi // (undocumented) getOffsetWidth(): number; // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration; // (undocumented) static ɵfac: i0.ɵɵFactoryDeclaration; @@ -364,21 +348,13 @@ export class _MatTabLinkBase extends _MatTabLinkMixinBase implements AfterViewIn constructor(_tabNavBar: _MatTabNavBase, elementRef: ElementRef, globalRippleOptions: RippleGlobalOptions | null, tabIndex: string, _focusMonitor: FocusMonitor, animationMode?: string); get active(): boolean; - set active(value: boolean); + set active(value: BooleanInput); elementRef: ElementRef; focus(): void; // (undocumented) _handleFocus(): void; protected _isActive: boolean; // (undocumented) - static ngAcceptInputType_active: BooleanInput; - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) ngAfterViewInit(): void; // (undocumented) ngOnDestroy(): void; @@ -400,8 +376,6 @@ export class MatTabNav extends _MatTabNavBase { // (undocumented) _nextPaginator: ElementRef; // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) _previousPaginator: ElementRef; // (undocumented) _tabList: ElementRef; @@ -421,8 +395,8 @@ export abstract class _MatTabNavBase extends MatPaginatedTabHeader implements Af get backgroundColor(): ThemePalette; set backgroundColor(value: ThemePalette); color: ThemePalette; - get disableRipple(): any; - set disableRipple(value: any); + get disableRipple(): boolean; + set disableRipple(value: BooleanInput); abstract _items: QueryList; diff --git a/tools/public_api_guard/material/tooltip.md b/tools/public_api_guard/material/tooltip.md index 6cbe483528cd..e00038c4656a 100644 --- a/tools/public_api_guard/material/tooltip.md +++ b/tools/public_api_guard/material/tooltip.md @@ -84,7 +84,7 @@ export abstract class _MatTooltipBase implement // (undocumented) protected _dir: Directionality; get disabled(): boolean; - set disabled(value: boolean); + set disabled(value: BooleanInput); _getOrigin(): { main: OriginConnectionPosition; fallback: OriginConnectionPosition; @@ -94,17 +94,12 @@ export abstract class _MatTooltipBase implement fallback: OverlayConnectionPosition; }; hide(delay?: number): void; - hideDelay: number; + get hideDelay(): number; + set hideDelay(value: NumberInput); _isTooltipVisible(): boolean; get message(): string; set message(value: string); // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_hideDelay: NumberInput; - // (undocumented) - static ngAcceptInputType_showDelay: NumberInput; - // (undocumented) ngAfterViewInit(): void; ngOnDestroy(): void; // (undocumented) @@ -112,7 +107,8 @@ export abstract class _MatTooltipBase implement get position(): TooltipPosition; set position(value: TooltipPosition); show(delay?: number): void; - showDelay: number; + get showDelay(): number; + set showDelay(value: NumberInput); toggle(): void; get tooltipClass(): string | string[] | Set | { [key: string]: any; diff --git a/tools/public_api_guard/material/tree.md b/tools/public_api_guard/material/tree.md index b8f9ddc2a93f..4d2ca3a73087 100644 --- a/tools/public_api_guard/material/tree.md +++ b/tools/public_api_guard/material/tree.md @@ -35,10 +35,8 @@ import { ViewContainerRef } from '@angular/core'; // @public export class MatNestedTreeNode extends CdkNestedTreeNode implements AfterContentInit, OnDestroy, OnInit { constructor(elementRef: ElementRef, tree: CdkTree, differs: IterableDiffers, tabIndex: string); - get disabled(): any; - set disabled(value: any); - // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; + get disabled(): boolean; + set disabled(value: BooleanInput); // (undocumented) ngAfterContentInit(): void; // (undocumented) @@ -120,10 +118,6 @@ export class MatTreeNestedDataSource extends DataSource { export class MatTreeNode extends _MatTreeNodeBase implements CanDisable, HasTabIndex, OnInit, OnDestroy { constructor(elementRef: ElementRef, tree: CdkTree, tabIndex: string); // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) ngOnDestroy(): void; // (undocumented) ngOnInit(): void; @@ -161,7 +155,7 @@ export class MatTreeNodePadding extends CdkTreeNodePadding { get indent(): number | string; set indent(indent: number | string); get level(): number; - set level(value: number); + set level(value: NumberInput); // (undocumented) static ɵdir: i0.ɵɵDirectiveDeclaration, "[matTreeNodePadding]", never, { "level": "matTreeNodePadding"; "indent": "matTreeNodePaddingIndent"; }, {}, never>; // (undocumented) diff --git a/tools/tslint-rules/coercionTypesRule.ts b/tools/tslint-rules/coercionTypesRule.ts deleted file mode 100644 index e677b47c7b67..000000000000 --- a/tools/tslint-rules/coercionTypesRule.ts +++ /dev/null @@ -1,315 +0,0 @@ -import * as ts from 'typescript'; -import * as Lint from 'tslint'; -import * as tsutils from 'tsutils'; - -const TYPE_ACCEPT_MEMBER_PREFIX = 'ngAcceptInputType_'; - -/** - * Type that describes the TypeScript type checker with internal methods for - * the type relation API methods being exposed. - */ -// TODO: remove if https://github.com/microsoft/TypeScript/issues/9879 is resolved. -type TypeCheckerWithRelationApi = ts.TypeChecker & { - getNullType: () => ts.Type; - getUndefinedType: () => ts.Type; - isTypeAssignableTo: (a: ts.Type, b: ts.Type) => boolean; -}; - -/** - * TSLint rule that verifies that classes declare corresponding `ngAcceptInputType_*` - * static fields for inputs that use coercion inside of their setters. Also handles - * inherited class members and members that come from an interface. - */ -export class Rule extends Lint.Rules.TypedRule { - applyWithProgram(sourceFile: ts.SourceFile, program: ts.Program): Lint.RuleFailure[] { - const walker = new Walker( - sourceFile, - this.getOptions(), - program.getTypeChecker() as TypeCheckerWithRelationApi, - ); - return this.applyWithWalker(walker); - } -} - -class Walker extends Lint.RuleWalker { - /** Names of the coercion functions that we should be looking for. */ - private _coercionFunctions: Set; - - /** Mapping of interfaces known to have coercion properties and the property names themselves. */ - private _coercionInterfaces: {[interfaceName: string]: string[]}; - - /** Type resolving to the TS internal `null` type. */ - private _nullType = this._typeChecker.getNullType(); - - /** Type resolving to the TS internal `undefined` type. */ - private _undefinedType = this._typeChecker.getUndefinedType(); - - constructor( - sourceFile: ts.SourceFile, - options: Lint.IOptions, - private _typeChecker: TypeCheckerWithRelationApi, - ) { - super(sourceFile, options); - this._coercionFunctions = new Set(options.ruleArguments[0] || []); - this._coercionInterfaces = options.ruleArguments[1] || {}; - } - - override visitPropertyDeclaration(node: ts.PropertyDeclaration) { - if (ts.isIdentifier(node.name) && node.name.text.startsWith(TYPE_ACCEPT_MEMBER_PREFIX)) { - this._lintCoercionMember(node); - } - super.visitPropertyDeclaration(node); - } - - override visitClassDeclaration(node: ts.ClassDeclaration) { - if (this._shouldLintClass(node)) { - this._lintClass(node, node, true); - this._lintSuperClasses(node); - this._lintInterfaces(node, node, true); - } - super.visitClassDeclaration(node); - } - - /** - * Checks if the given property declaration of a coercion member includes null and - * undefined in the type node. We enforce that all acceptance members accept these - * values since we want coercion inputs to work with the async pipe. - */ - private _lintCoercionMember(node: ts.PropertyDeclaration) { - if (!node.type) { - this.addFailureAtNode(node, 'Acceptance member needs to have an explicit type.'); - return; - } - - const type = this._typeChecker.getTypeFromTypeNode(node.type); - const hasUndefined = this._typeChecker.isTypeAssignableTo(this._undefinedType, type); - const hasNull = this._typeChecker.isTypeAssignableTo(this._nullType, type); - - if (!hasNull && !hasUndefined) { - this.addFailureAtNode( - node, - 'Acceptance member has to accept "null" and "undefined".', - this.appendText(node.type.getEnd(), ' | null | undefined'), - ); - } else if (!hasNull) { - this.addFailureAtNode( - node, - 'Acceptance member has to accept "null".', - this.appendText(node.type.getEnd(), ' | null'), - ); - } else if (!hasUndefined) { - this.addFailureAtNode( - node, - 'Acceptance member has to accept "undefined".', - this.appendText(node.type.getEnd(), ' | undefined'), - ); - } - } - - /** - * Goes through the own setters of a class declaration and checks whether they use coercion. - * @param node Class declaration to be checked. - * @param sourceClass Class declaration on which to look for static properties that declare the - * accepted values for the setter. - * @param expectDeclaredMembers Whether acceptance members should be expected or unexpected. - */ - private _lintClass( - node: ts.ClassDeclaration, - sourceClass: ts.ClassDeclaration, - expectDeclaredMembers: boolean, - ): void { - node.members.forEach(member => { - if ( - ts.isSetAccessor(member) && - usesCoercion(member, this._coercionFunctions) && - this._shouldCheckSetter(member) - ) { - this._checkStaticMember(sourceClass, member.name.getText(), expectDeclaredMembers); - } - }); - } - - /** - * Goes up the inheritance chain of a class declaration and - * checks whether it has any setters using coercion. - * @param node Class declaration to be checked. - */ - private _lintSuperClasses(node: ts.ClassDeclaration): void { - let currentClass: ts.ClassDeclaration | null = node; - - while (currentClass) { - const baseType = getBaseTypeIdentifier(currentClass); - - if (!baseType) { - break; - } - - const symbol = this._typeChecker.getTypeAtLocation(baseType).getSymbol(); - currentClass = - symbol?.valueDeclaration && ts.isClassDeclaration(symbol.valueDeclaration) - ? symbol.valueDeclaration - : null; - - if (currentClass) { - // Acceptance members should not be re-declared in the derived class. This - // is because acceptance members are inherited. - this._lintClass(currentClass, node, false); - this._lintInterfaces(currentClass, node, false); - } - } - } - - /** - * Checks whether the interfaces that a class implements contain any known coerced properties. - * @param node Class declaration to be checked. - * @param sourceClass Class declaration on which to look for static properties that declare the - * accepted values for the setter. - * @param expectDeclaredMembers Whether acceptance members should be expected or unexpected. - */ - private _lintInterfaces( - node: ts.ClassDeclaration, - sourceClass: ts.ClassDeclaration, - expectDeclaredMembers: boolean, - ): void { - if (!node.heritageClauses) { - return; - } - - node.heritageClauses.forEach(clause => { - if (clause.token === ts.SyntaxKind.ImplementsKeyword) { - clause.types.forEach(clauseType => { - if (ts.isIdentifier(clauseType.expression)) { - const propNames = this._coercionInterfaces[clauseType.expression.text]; - - if (propNames) { - propNames.forEach(propName => - this._checkStaticMember(sourceClass, propName, expectDeclaredMembers), - ); - } - } - }); - } - }); - } - - /** - * Based on whether the acceptance members are expected or not, this method checks whether - * the specified class declaration matches the condition. - */ - private _checkStaticMember( - node: ts.ClassDeclaration, - setterName: string, - expectDeclaredMembers: boolean, - ) { - const {memberName, memberNode} = this._lookupStaticMember(node, setterName); - if (expectDeclaredMembers && !memberNode) { - this.addFailureAtNode( - node.name || node, - `Class must declare static coercion ` + `property called ${memberName}.`, - ); - } else if (!expectDeclaredMembers && memberNode) { - this.addFailureAtNode( - node.name || node, - `Class should not declare static coercion ` + - `property called ${memberName}. Acceptance members are inherited.`, - Lint.Replacement.deleteText(memberNode.getFullStart(), memberNode.getFullWidth()), - ); - } - } - - /** Checks whether this rule should lint a class declaration. */ - private _shouldLintClass(node: ts.ClassDeclaration): boolean { - // We don't need to lint undecorated classes. - if (!node.decorators) { - return false; - } - // If the class is a component, we should lint it. - if (node.decorators.some(decorator => isDecoratorCalled(decorator, 'Component'))) { - return true; - } - // If the class is a directive, we should lint it. - return node.decorators.some(decorator => isDecoratorCalled(decorator, 'Directive')); - } - - /** Looks for a static member that corresponds to the given property. */ - private _lookupStaticMember( - node: ts.ClassDeclaration, - propName: string, - ): {memberName: string; memberNode?: ts.PropertyDeclaration} { - const coercionPropertyName = `${TYPE_ACCEPT_MEMBER_PREFIX}${propName}`; - const correspondingCoercionProperty = node.members.find( - (member): member is ts.PropertyDeclaration => { - return ( - ts.isPropertyDeclaration(member) && - tsutils.hasModifier(member.modifiers, ts.SyntaxKind.StaticKeyword) && - member.name.getText() === coercionPropertyName - ); - }, - ); - return {memberName: coercionPropertyName, memberNode: correspondingCoercionProperty}; - } - - /** Determines whether a setter node should be checked by the lint rule. */ - private _shouldCheckSetter(node: ts.SetAccessorDeclaration): boolean { - const param = node.parameters[0]; - const types = this._typeChecker - .typeToString(this._typeChecker.getTypeAtLocation(param)) - .split('|') - .map(name => name.trim()); - // We shouldn't check setters which accept `any` or a `string`. - return types.every(typeName => typeName !== 'any' && typeName !== 'string'); - } -} - -/** - * Checks whether a setter uses coercion. - * @param setter Setter node that should be checked. - * @param coercionFunctions Names of the coercion functions that we should be looking for. - */ -function usesCoercion(setter: ts.SetAccessorDeclaration, coercionFunctions: Set): boolean { - let coercionWasUsed = false; - - setter.forEachChild(function walk(node: ts.Node) { - if ( - ts.isCallExpression(node) && - ts.isIdentifier(node.expression) && - coercionFunctions.has(node.expression.text) - ) { - coercionWasUsed = true; - } - - // Don't check callback functions since coercion used - // inside them most-likely won't need to be declared. - if (!coercionWasUsed && !ts.isArrowFunction(node) && !ts.isFunctionExpression(node)) { - node.forEachChild(walk); - } - }); - - return coercionWasUsed; -} - -/** Gets the identifier node of the base type that a class is extending. */ -function getBaseTypeIdentifier(node: ts.ClassDeclaration): ts.Identifier | null { - if (node.heritageClauses) { - for (let clause of node.heritageClauses) { - if ( - clause.token === ts.SyntaxKind.ExtendsKeyword && - clause.types.length && - ts.isIdentifier(clause.types[0].expression) - ) { - return clause.types[0].expression; - } - } - } - - return null; -} - -/** Checks whether a node is a decorator with a particular name. */ -function isDecoratorCalled(node: ts.Decorator, name: string): boolean { - return ( - ts.isCallExpression(node.expression) && - ts.isIdentifier(node.expression.expression) && - node.expression.expression.text === name - ); -} diff --git a/tools/tslint-rules/noCoercionMembersRule.ts b/tools/tslint-rules/noCoercionMembersRule.ts new file mode 100644 index 000000000000..c07da6de8616 --- /dev/null +++ b/tools/tslint-rules/noCoercionMembersRule.ts @@ -0,0 +1,28 @@ +import * as ts from 'typescript'; +import * as Lint from 'tslint'; + +/** Lint rule that disallows coercion class members. */ +export class Rule extends Lint.Rules.AbstractRule { + apply(sourceFile: ts.SourceFile) { + return this.applyWithFunction( + sourceFile, + (context: Lint.WalkContext) => { + (function visitNode(node: ts.Node) { + if (ts.isClassDeclaration(node)) { + node.members.forEach(member => { + if (member.name?.getText().startsWith('ngAcceptInputType_')) { + context.addFailureAtNode( + member, + 'Coercion members are not allowed. Add the type to the input setter instead.', + ); + } + }); + } + + ts.forEachChild(node, visitNode); + })(context.sourceFile); + }, + this.getOptions().ruleArguments, + ); + } +} diff --git a/tslint.json b/tslint.json index 99fd9c7a7bdf..c2433bd22e07 100644 --- a/tslint.json +++ b/tslint.json @@ -100,14 +100,7 @@ // need a dedicated token. ["Directionality", "DateAdapter"] ], - "coercion-types": [true, - ["coerceBooleanProperty", "coerceCssPixelValue", "coerceNumberProperty"], - { - "CanDisable": ["disabled"], - "CanDisableRipple": ["disableRipple"], - "HasTabIndex": ["tabIndex"] - } - ], + "no-coercion-members": true, "no-host-decorator-in-concrete": [ true, "HostBinding",