From 2d97f992e1457348fd7c0ac110b8b75555d18a58 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Mon, 20 Sep 2021 19:44:40 +0200 Subject: [PATCH] refactor(multiple): remove coercion members * Drops support for TypeScript 4.2. There's a PR that does this already on the Framework side: https://github.com/angular/angular/pull/43281. * Replaces all usages of the `ngAcceptInputType` members with type declarations directly on the setters. * Replaces the lint rule that was checking that the correct coercion members were added with a rule that doesn't allow new coercion members to be added. --- CODING_STANDARDS.md | 10 +- integration/ts-compat/BUILD.bazel | 1 - package.json | 1 - src/cdk-experimental/combobox/combobox.ts | 14 +- src/cdk-experimental/listbox/listbox.ts | 25 +- src/cdk-experimental/menu/context-menu.ts | 6 +- .../menu/menu-item-selectable.ts | 6 +- src/cdk-experimental/menu/menu-item.ts | 4 +- .../scrolling/auto-size-virtual-scroll.ts | 7 +- .../selection/row-selection.ts | 4 +- .../selection/selection-toggle.ts | 4 +- src/cdk-experimental/selection/selection.ts | 4 +- src/cdk/a11y/focus-trap/focus-trap.ts | 7 +- src/cdk/accordion/accordion-item.ts | 7 +- src/cdk/accordion/accordion.ts | 4 +- src/cdk/coercion/coercion.md | 8 +- src/cdk/drag-drop/directives/drag-handle.ts | 4 +- src/cdk/drag-drop/directives/drag-preview.ts | 4 +- src/cdk/drag-drop/directives/drag.ts | 4 +- .../drag-drop/directives/drop-list-group.ts | 4 +- src/cdk/drag-drop/directives/drop-list.ts | 13 +- src/cdk/observers/observe-content.ts | 9 +- src/cdk/overlay/overlay-directives.ts | 26 +- src/cdk/portal/portal-directives.ts | 6 +- .../scrolling/fixed-size-virtual-scroll.ts | 10 +- src/cdk/scrolling/virtual-for-of.ts | 6 +- src/cdk/scrolling/virtual-scroll-viewport.ts | 4 +- src/cdk/stepper/stepper.ts | 30 +- src/cdk/table/can-stick.ts | 4 +- src/cdk/table/cell.ts | 5 +- src/cdk/table/row.ts | 5 - src/cdk/table/table.ts | 7 +- src/cdk/text-field/autosize.ts | 10 +- src/cdk/tree/padding.ts | 6 +- src/cdk/tree/toggle.ts | 4 +- .../form-field-custom-control-example.ts | 7 +- .../form-field-custom-control-example.ts | 7 +- src/dev-app/example/example-list.ts | 4 +- src/dev-app/example/example.ts | 4 +- .../mdc-button/button-base.ts | 4 - src/material-experimental/mdc-button/fab.ts | 12 +- .../mdc-checkbox/checkbox.ts | 14 +- .../mdc-chips/chip-grid.ts | 10 +- .../mdc-chips/chip-icons.ts | 4 - .../mdc-chips/chip-input.ts | 7 +- .../mdc-chips/chip-listbox.ts | 10 +- .../mdc-chips/chip-option.ts | 7 +- .../mdc-chips/chip-row.ts | 3 - .../mdc-chips/chip-set.ts | 7 +- src/material-experimental/mdc-chips/chip.ts | 16 +- .../mdc-form-field/form-field.ts | 4 +- .../mdc-list/list-base.ts | 14 +- .../mdc-list/list-option.ts | 4 +- .../mdc-list/selection-list.ts | 4 +- .../mdc-progress-spinner/progress-spinner.ts | 10 +- .../mdc-slide-toggle/slide-toggle.ts | 16 +- .../mdc-slider/slider.ts | 24 +- .../mdc-tabs/tab-group.ts | 4 +- .../mdc-tabs/tab-header.ts | 3 - .../mdc-tabs/tab-label-wrapper.ts | 6 +- .../mdc-tabs/tab-nav-bar/tab-nav-bar.ts | 5 +- .../autocomplete/autocomplete-trigger.ts | 4 +- src/material/autocomplete/autocomplete.ts | 5 +- src/material/badge/badge.ts | 8 +- src/material/button-toggle/button-toggle.ts | 20 +- src/material/button/button.ts | 4 - src/material/checkbox/checkbox.ts | 16 +- src/material/chips/chip-input.ts | 7 +- src/material/chips/chip-list.ts | 13 +- src/material/chips/chip.ts | 17 +- .../core/common-behaviors/disable-ripple.ts | 2 +- .../core/common-behaviors/disabled.ts | 2 +- src/material/core/option/optgroup.ts | 3 - src/material/core/option/option.ts | 8 +- src/material/datepicker/date-range-input.ts | 7 +- src/material/datepicker/datepicker-base.ts | 13 +- .../datepicker/datepicker-input-base.ts | 9 +- src/material/datepicker/datepicker-toggle.ts | 4 +- src/material/divider/divider.ts | 7 +- src/material/expansion/accordion.ts | 4 +- .../expansion/expansion-panel-header.ts | 3 - src/material/expansion/expansion-panel.ts | 4 +- src/material/form-field/form-field.ts | 4 +- src/material/grid-list/grid-list.ts | 4 +- src/material/grid-list/grid-tile.ts | 7 +- src/material/icon/icon.ts | 4 +- src/material/input/input.ts | 16 +- src/material/list/list.ts | 13 +- src/material/list/selection-list.ts | 20 +- src/material/menu/menu-item.ts | 4 - src/material/menu/menu.ts | 7 +- src/material/paginator/paginator.ts | 21 +- src/material/progress-bar/progress-bar.ts | 4 +- .../progress-spinner/progress-spinner.ts | 10 +- src/material/radio/radio.ts | 20 +- src/material/select/select.ts | 16 +- src/material/sidenav/drawer.ts | 27 +- src/material/sidenav/sidenav.ts | 10 +- src/material/slide-toggle/slide-toggle.ts | 12 +- src/material/slider/slider.ts | 29 +- src/material/sort/sort-header.ts | 5 +- src/material/sort/sort.ts | 5 +- src/material/tabs/paginated-tab-header.ts | 4 +- src/material/tabs/tab-group.ts | 12 +- src/material/tabs/tab-header.ts | 6 +- src/material/tabs/tab-label-wrapper.ts | 3 - src/material/tabs/tab-nav-bar/tab-nav-bar.ts | 17 +- src/material/tabs/tab.ts | 3 - src/material/tooltip/tooltip.ts | 27 +- src/material/tree/node.ts | 11 +- src/material/tree/padding.ts | 3 +- tools/dgeni/common/private-docs.ts | 3 +- tools/public_api_guard/cdk/a11y.md | 8 +- tools/public_api_guard/cdk/accordion.md | 12 +- tools/public_api_guard/cdk/drag-drop.md | 32 +-- tools/public_api_guard/cdk/observers.md | 10 +- tools/public_api_guard/cdk/overlay.md | 24 +- tools/public_api_guard/cdk/portal.md | 4 +- tools/public_api_guard/cdk/scrolling.md | 20 +- tools/public_api_guard/cdk/stepper.md | 32 +-- tools/public_api_guard/cdk/table.md | 18 +- tools/public_api_guard/cdk/text-field.md | 12 +- tools/public_api_guard/cdk/tree.md | 10 +- .../public_api_guard/material/autocomplete.md | 10 +- tools/public_api_guard/material/badge.md | 10 +- .../material/button-toggle.md | 26 +- tools/public_api_guard/material/button.md | 5 - tools/public_api_guard/material/checkbox.md | 21 +- tools/public_api_guard/material/chips.md | 45 +-- tools/public_api_guard/material/core.md | 10 +- tools/public_api_guard/material/datepicker.md | 28 +- tools/public_api_guard/material/divider.md | 8 +- tools/public_api_guard/material/expansion.md | 11 +- tools/public_api_guard/material/form-field.md | 4 +- tools/public_api_guard/material/grid-list.md | 12 +- tools/public_api_guard/material/icon.md | 4 +- tools/public_api_guard/material/input.md | 16 +- tools/public_api_guard/material/list.md | 38 +-- tools/public_api_guard/material/menu.md | 12 +- tools/public_api_guard/material/paginator.md | 22 +- .../public_api_guard/material/progress-bar.md | 4 +- .../material/progress-spinner.md | 12 +- tools/public_api_guard/material/radio.md | 25 +- tools/public_api_guard/material/select.md | 22 +- tools/public_api_guard/material/sidenav.md | 34 +-- .../public_api_guard/material/slide-toggle.md | 15 +- tools/public_api_guard/material/slider.md | 36 +-- tools/public_api_guard/material/sort.md | 12 +- tools/public_api_guard/material/tabs.md | 42 +-- tools/public_api_guard/material/tooltip.md | 14 +- tools/public_api_guard/material/tree.md | 12 +- tools/tslint-rules/coercionTypesRule.ts | 269 ------------------ tools/tslint-rules/noCoercionMembersRule.ts | 22 ++ tslint.json | 9 +- yarn.lock | 5 - 155 files changed, 462 insertions(+), 1505 deletions(-) delete mode 100644 tools/tslint-rules/coercionTypesRule.ts create mode 100644 tools/tslint-rules/noCoercionMembersRule.ts 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/integration/ts-compat/BUILD.bazel b/integration/ts-compat/BUILD.bazel index aad5abe28467..51789653fe09 100644 --- a/integration/ts-compat/BUILD.bazel +++ b/integration/ts-compat/BUILD.bazel @@ -13,7 +13,6 @@ write_file( # List of TypeScript packages that we want to run the compatibility test against. # The list contains NPM module names that resolve to the desired TypeScript version. typescript_version_packages = [ - "typescript-4.2", "typescript", ] diff --git a/package.json b/package.json index 104af03a3be3..71121c51690e 100644 --- a/package.json +++ b/package.json @@ -227,7 +227,6 @@ "tslint": "^6.1.3", "tsutils": "^3.21.0", "typescript": "~4.3.2", - "typescript-4.2": "npm:typescript@4.2.3", "vrsource-tslint-rules": "6.0.0", "yaml": "^1.10.0" }, diff --git a/src/cdk-experimental/combobox/combobox.ts b/src/cdk-experimental/combobox/combobox.ts index d3715a0cb485..995b84482922 100644 --- a/src/cdk-experimental/combobox/combobox.ts +++ b/src/cdk-experimental/combobox/combobox.ts @@ -64,14 +64,14 @@ export class CdkCombobox implements OnDestroy, AfterContentInit { @Input() get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value); } + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled: boolean = false; @Input() get openActions(): OpenAction[] { return this._openActions; } - set openActions(action: OpenAction[]) { + set openActions(action: OpenActionInput) { this._openActions = this._coerceOpenActionProperty(action); } private _openActions: OpenAction[] = ['click']; @@ -79,7 +79,7 @@ export class CdkCombobox implements OnDestroy, AfterContentInit { /** Whether the textContent is automatically updated upon change of the combobox value. */ @Input() get autoSetText(): boolean { return this._autoSetText; } - set autoSetText(value: boolean) { this._autoSetText = coerceBooleanProperty(value); } + set autoSetText(value: BooleanInput) { this._autoSetText = coerceBooleanProperty(value); } private _autoSetText: boolean = true; @Output('comboboxPanelOpened') readonly opened: EventEmitter = new EventEmitter(); @@ -276,16 +276,12 @@ 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 || 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 aab60456e99c..99d2ba9a3dde 100644 --- a/src/cdk-experimental/listbox/listbox.ts +++ b/src/cdk-experimental/listbox/listbox.ts @@ -67,7 +67,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); } @@ -77,7 +77,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); } @@ -191,9 +191,6 @@ export class CdkOption implements ListKeyManagerOption, Highlightab setInactiveStyles() { this._active = false; } - - static ngAcceptInputType_selected: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } @Directive({ @@ -256,16 +253,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); } @@ -274,7 +272,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); } @@ -283,7 +281,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); } @@ -547,11 +545,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 226db1788436..5f0ebd7f6b94 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; @@ -324,6 +324,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 e530efda3eac..48b41ba25bba 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 ea6e067931fd..e7e6baf508f5 100644 --- a/src/cdk-experimental/menu/menu-item.ts +++ b/src/cdk-experimental/menu/menu-item.ts @@ -61,7 +61,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; @@ -276,6 +276,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 418ac03c87ca..3756404e06cf 100644 --- a/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts +++ b/src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts @@ -447,7 +447,7 @@ export class CdkAutoSizeVirtualScroll implements OnChanges { */ @Input() get minBufferPx(): number { return this._minBufferPx; } - set minBufferPx(value: number) { this._minBufferPx = coerceNumberProperty(value); } + set minBufferPx(value: NumberInput) { this._minBufferPx = coerceNumberProperty(value); } _minBufferPx = 100; /** @@ -458,7 +458,7 @@ export class CdkAutoSizeVirtualScroll implements OnChanges { */ @Input() get maxBufferPx(): number { return this._maxBufferPx; } - set maxBufferPx(value: number) { this._maxBufferPx = coerceNumberProperty(value); } + set maxBufferPx(value: NumberInput) { this._maxBufferPx = coerceNumberProperty(value); } _maxBufferPx = 200; /** The scroll strategy used by this directive. */ @@ -467,7 +467,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 cacde2ce5a50..60dc823af5a9 100644 --- a/src/cdk-experimental/selection/row-selection.ts +++ b/src/cdk-experimental/selection/row-selection.ts @@ -30,10 +30,8 @@ export class CdkRowSelection { @Input('cdkRowSelectionIndex') get index(): number|undefined { return this._index; } - set index(index: number|undefined) { this._index = coerceNumberProperty(index); } + 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 be501a69f7ee..a6936b6ca5e4 100644 --- a/src/cdk-experimental/selection/selection-toggle.ts +++ b/src/cdk-experimental/selection/selection-toggle.ts @@ -43,7 +43,7 @@ export class CdkSelectionToggle implements OnDestroy, OnInit { /** The index of the value in the list. Required when used with `trackBy` */ @Input('cdkSelectionToggleIndex') get index(): number|undefined { return this._index; } - set index(index: number|undefined) { this._index = coerceNumberProperty(index); } + set index(index: NumberInput) { this._index = coerceNumberProperty(index); } protected _index?: number; /** The checked state of the selection toggle */ @@ -98,6 +98,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 f6ca11ff2ab3..3bb00b6dd69b 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; @@ -214,8 +214,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 31c6ac98e611..c3fd9c983218 100644 --- a/src/cdk/a11y/focus-trap/focus-trap.ts +++ b/src/cdk/a11y/focus-trap/focus-trap.ts @@ -395,7 +395,7 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit, OnChanges, DoC /** Whether the focus trap is active. */ @Input('cdkTrapFocus') get enabled(): boolean { return this.focusTrap.enabled; } - set enabled(value: boolean) { this.focusTrap.enabled = coerceBooleanProperty(value); } + set enabled(value: BooleanInput) { this.focusTrap.enabled = coerceBooleanProperty(value); } /** * Whether the directive should automatically move focus into the trapped region upon @@ -403,7 +403,7 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit, OnChanges, DoC */ @Input('cdkTrapFocusAutoCapture') get autoCapture(): boolean { return this._autoCapture; } - set autoCapture(value: boolean) { this._autoCapture = coerceBooleanProperty(value); } + set autoCapture(value: BooleanInput) { this._autoCapture = coerceBooleanProperty(value); } private _autoCapture: boolean; constructor( @@ -455,7 +455,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 c5f1bc8bc6ed..f065a99f8f3c 100644 --- a/src/cdk/accordion/accordion-item.ts +++ b/src/cdk/accordion/accordion-item.ts @@ -61,7 +61,7 @@ export class CdkAccordionItem implements OnDestroy { /** Whether the AccordionItem is expanded. */ @Input() 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. @@ -91,7 +91,7 @@ export class CdkAccordionItem implements OnDestroy { /** Whether the AccordionItem is disabled. */ @Input() get disabled(): boolean { return this._disabled; } - set disabled(disabled: boolean) { this._disabled = coerceBooleanProperty(disabled); } + set disabled(disabled: BooleanInput) { this._disabled = coerceBooleanProperty(disabled); } private _disabled = false; /** Unregister function for _expansionDispatcher. */ @@ -153,7 +153,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 89cfeb555571..e298af6a62aa 100644 --- a/src/cdk/accordion/accordion.ts +++ b/src/cdk/accordion/accordion.ts @@ -41,7 +41,7 @@ export class CdkAccordion implements OnDestroy, OnChanges { /** Whether the accordion should allow multiple expanded accordion items simultaneously. */ @Input() get multi(): boolean { return this._multi; } - set multi(multi: boolean) { this._multi = coerceBooleanProperty(multi); } + set multi(multi: BooleanInput) { this._multi = coerceBooleanProperty(multi); } private _multi: boolean = false; /** Opens all enabled accordion items in an accordion where multi is enabled. */ @@ -64,6 +64,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 6a6fdd3058c2..de614e52663c 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 d9ff06137988..c4b6a0936f32 100644 --- a/src/cdk/drag-drop/directives/drag-handle.ts +++ b/src/cdk/drag-drop/directives/drag-handle.ts @@ -46,7 +46,7 @@ export class CdkDragHandle implements OnDestroy { /** Whether starting to drag through this handle is disabled. */ @Input('cdkDragHandleDisabled') get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._stateChanges.next(this); } @@ -66,6 +66,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 7fe926ec1e83..9b7f3902b4a3 100644 --- a/src/cdk/drag-drop/directives/drag-preview.ts +++ b/src/cdk/drag-drop/directives/drag-preview.ts @@ -31,10 +31,8 @@ export class CdkDragPreview { /** Whether the preview should preserve the same size as the item that is being dragged. */ @Input() get matchSize(): boolean { return this._matchSize; } - set matchSize(value: boolean) { this._matchSize = coerceBooleanProperty(value); } + 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 fb2d216f81fd..96001063d077 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; } @@ -546,6 +546,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 8b3d43f2ea7f..2f4324ad147d 100644 --- a/src/cdk/drag-drop/directives/drop-list-group.ts +++ b/src/cdk/drag-drop/directives/drop-list-group.ts @@ -35,7 +35,7 @@ export class CdkDropListGroup implements OnDestroy { /** Whether starting a dragging sequence from inside this group is disabled. */ @Input('cdkDropListGroupDisabled') get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; @@ -43,6 +43,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 691b313e7584..9f66ca5cb521 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') @@ -388,9 +388,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 849d13894d5d..166f05b9fce4 100644 --- a/src/cdk/observers/observe-content.ts +++ b/src/cdk/observers/observe-content.ts @@ -148,8 +148,8 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy { * to disconnect the underlying MutationObserver until it is needed. */ @Input('cdkObserveContentDisabled') - get disabled() { return this._disabled; } - set disabled(value: any) { + get disabled(): boolean { return this._disabled; } + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._disabled ? this._unsubscribe() : this._subscribe(); } @@ -158,7 +158,7 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy { /** Debounce interval for emitting the changes. */ @Input() get debounce(): number { return this._debounce; } - set debounce(value: number) { + set debounce(value: NumberInput) { this._debounce = coerceNumberProperty(value); this._subscribe(); } @@ -197,9 +197,6 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy { private _unsubscribe() { this._currentSubscription?.unsubscribe(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_debounce: NumberInput; } diff --git a/src/cdk/overlay/overlay-directives.ts b/src/cdk/overlay/overlay-directives.ts index bcebf3c5a82d..4e47c205356f 100644 --- a/src/cdk/overlay/overlay-directives.ts +++ b/src/cdk/overlay/overlay-directives.ts @@ -184,30 +184,30 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges { /** Whether or not the overlay should attach a backdrop. */ @Input('cdkConnectedOverlayHasBackdrop') - get hasBackdrop() { return this._hasBackdrop; } - set hasBackdrop(value: any) { this._hasBackdrop = coerceBooleanProperty(value); } + get hasBackdrop(): boolean { return this._hasBackdrop; } + set hasBackdrop(value: BooleanInput) { this._hasBackdrop = coerceBooleanProperty(value); } /** Whether or not the overlay should be locked when scrolling. */ @Input('cdkConnectedOverlayLockPosition') - get lockPosition() { return this._lockPosition; } - set lockPosition(value: any) { this._lockPosition = coerceBooleanProperty(value); } + get lockPosition(): boolean { return this._lockPosition; } + 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() { return this._flexibleDimensions; } - set flexibleDimensions(value: boolean) { + get flexibleDimensions(): boolean { return this._flexibleDimensions; } + 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() { return this._growAfterOpen; } - set growAfterOpen(value: boolean) { this._growAfterOpen = coerceBooleanProperty(value); } + get growAfterOpen(): boolean { return this._growAfterOpen; } + 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() { return this._push; } - set push(value: boolean) { this._push = coerceBooleanProperty(value); } + get push(): boolean { return this._push; } + set push(value: BooleanInput) { this._push = coerceBooleanProperty(value); } /** Event emitted when the backdrop is clicked. */ @Output() readonly backdropClick = new EventEmitter(); @@ -427,12 +427,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 f7a343f4c529..a7f987ba637c 100644 --- a/src/cdk/portal/portal-directives.ts +++ b/src/cdk/portal/portal-directives.ts @@ -97,7 +97,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 @@ -114,7 +114,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. */ @@ -232,8 +232,6 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr return (nativeElement.nodeType === nativeElement.ELEMENT_NODE ? nativeElement : 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 350852b38312..030ea124c262 100644 --- a/src/cdk/scrolling/fixed-size-virtual-scroll.ts +++ b/src/cdk/scrolling/fixed-size-virtual-scroll.ts @@ -198,7 +198,7 @@ export class CdkFixedSizeVirtualScroll implements OnChanges { /** The size of the items in the list (in pixels). */ @Input() get itemSize(): number { return this._itemSize; } - set itemSize(value: number) { this._itemSize = coerceNumberProperty(value); } + set itemSize(value: NumberInput) { this._itemSize = coerceNumberProperty(value); } _itemSize = 20; /** @@ -207,7 +207,7 @@ export class CdkFixedSizeVirtualScroll implements OnChanges { */ @Input() get minBufferPx(): number { return this._minBufferPx; } - set minBufferPx(value: number) { this._minBufferPx = coerceNumberProperty(value); } + set minBufferPx(value: NumberInput) { this._minBufferPx = coerceNumberProperty(value); } _minBufferPx = 100; /** @@ -215,7 +215,7 @@ export class CdkFixedSizeVirtualScroll implements OnChanges { */ @Input() get maxBufferPx(): number { return this._maxBufferPx; } - set maxBufferPx(value: number) { this._maxBufferPx = coerceNumberProperty(value); } + set maxBufferPx(value: NumberInput) { this._maxBufferPx = coerceNumberProperty(value); } _maxBufferPx = 200; /** The scroll strategy used by this directive. */ @@ -225,8 +225,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 e42026694aa8..76df3c8554f7 100644 --- a/src/cdk/scrolling/virtual-for-of.ts +++ b/src/cdk/scrolling/virtual-for-of.ts @@ -143,10 +143,10 @@ export class CdkVirtualForOf implements * 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); } @@ -381,6 +381,4 @@ export class CdkVirtualForOf implements index, }; } - - static ngAcceptInputType_cdkVirtualForTemplateCacheSize: NumberInput; } diff --git a/src/cdk/scrolling/virtual-scroll-viewport.ts b/src/cdk/scrolling/virtual-scroll-viewport.ts index 0d85b61e3b31..66678ef21315 100644 --- a/src/cdk/scrolling/virtual-scroll-viewport.ts +++ b/src/cdk/scrolling/virtual-scroll-viewport.ts @@ -98,7 +98,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; @@ -449,6 +449,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 7f555569dae5..741a660d6b87 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; @@ -245,11 +245,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({ @@ -280,22 +275,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`.'); } @@ -303,7 +298,7 @@ export class CdkStepper implements AfterContentInit, AfterViewInit, OnDestroy { if (this._selectedIndex !== newIndex && !this._anyControlsInvalidOrPending(newIndex) && (newIndex >= this._selectedIndex || this.steps.toArray()[newIndex].editable)) { - this._updateSelectedItemIndex(index); + this._updateSelectedItemIndex(newIndex); } } else { this._selectedIndex = newIndex; @@ -570,13 +565,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 f4f58771f9cf..48dcadf6fdce 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; @@ -44,7 +44,7 @@ export function mixinHasStickyInput>(base: T): CanStic return class extends base { /** Whether sticky positioning should be applied. */ 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 ebf085e58654..07f1a10ba99f 100644 --- a/src/cdk/table/cell.ts +++ b/src/cdk/table/cell.ts @@ -83,7 +83,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; @@ -142,9 +142,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 e1f30d7a2727..4c416fbc1274 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, @@ -107,8 +106,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. @@ -138,8 +135,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 dcfec39e5432..9a2ff3a63096 100644 --- a/src/cdk/table/table.ts +++ b/src/cdk/table/table.ts @@ -428,7 +428,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. ), @@ -448,7 +448,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. @@ -1249,9 +1249,6 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes } } } - - 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 c6f96fdaf16d..c9afce91db86 100644 --- a/src/cdk/text-field/autosize.ts +++ b/src/cdk/text-field/autosize.ts @@ -62,7 +62,7 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy { /** Minimum amount of rows in the textarea. */ @Input('cdkAutosizeMinRows') get minRows(): number { return this._minRows; } - set minRows(value: number) { + set minRows(value: NumberInput) { this._minRows = coerceNumberProperty(value); this._setMinHeight(); } @@ -70,7 +70,7 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy { /** Maximum amount of rows in the textarea. */ @Input('cdkAutosizeMaxRows') get maxRows(): number { return this._maxRows; } - set maxRows(value: number) { + set maxRows(value: NumberInput) { this._maxRows = coerceNumberProperty(value); this._setMaxHeight(); } @@ -78,7 +78,7 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy { /** Whether autosizing is enabled or not */ @Input('cdkTextareaAutosize') 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 @@ -364,8 +364,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 9c0e483694da..a19f8382b3dd 100644 --- a/src/cdk/tree/padding.ts +++ b/src/cdk/tree/padding.ts @@ -36,7 +36,7 @@ export class CdkTreeNodePadding implements OnDestroy { /** The level of depth of the tree node. The padding will be `level * indent` pixels. */ @Input('cdkTreeNodePadding') get level(): number { return this._level; } - set level(value: number) { this._setLevelInput(value); } + set level(value: NumberInput) { this._setLevelInput(value); } _level: number; /** @@ -96,7 +96,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. @@ -124,6 +124,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 9d6c16a5ea96..b27b5aeff9a2 100644 --- a/src/cdk/tree/toggle.ts +++ b/src/cdk/tree/toggle.ts @@ -19,7 +19,7 @@ export class CdkTreeNodeToggle { /** Whether expand/collapse the node recursively. */ @Input('cdkTreeNodeToggleRecursive') get recursive(): boolean { return this._recursive; } - set recursive(value: boolean) { this._recursive = coerceBooleanProperty(value); } + set recursive(value: BooleanInput) { this._recursive = coerceBooleanProperty(value); } protected _recursive = false; constructor(protected _tree: CdkTree, @@ -38,6 +38,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 7adc4cff9f26..a8b992b41296 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 @@ -61,7 +61,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 6203121975c0..f69225031767 100644 --- a/src/material-experimental/mdc-button/fab.ts +++ b/src/material-experimental/mdc-button/fab.ts @@ -87,9 +87,9 @@ 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) { this._extended = coerceBooleanProperty(value); } + set extended(value: BooleanInput) { this._extended = coerceBooleanProperty(value); } + private _extended: boolean; constructor( elementRef: ElementRef, platform: Platform, ngZone: NgZone, @@ -99,8 +99,6 @@ export class MatFabButton extends MatButtonBase { this._options = this._options || defaults; this.color = this.defaultColor = this._options!.color || defaults.color; } - - static ngAcceptInputType_extended: BooleanInput; } /** @@ -171,9 +169,9 @@ 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) { this._extended = coerceBooleanProperty(value); } + set extended(value: BooleanInput) { this._extended = coerceBooleanProperty(value); } + private _extended: boolean; constructor( @@ -184,8 +182,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 5056ce39d26d..7529c9875baa 100644 --- a/src/material-experimental/mdc-checkbox/checkbox.ts +++ b/src/material-experimental/mdc-checkbox/checkbox.ts @@ -117,7 +117,7 @@ export class MatCheckbox extends _MatCheckboxBase implements AfterViewInit, OnDe get checked(): boolean { return this._checked; } - set checked(checked) { + set checked(checked: BooleanInput) { this._checked = coerceBooleanProperty(checked); } private _checked = false; @@ -132,7 +132,7 @@ export class MatCheckbox extends _MatCheckboxBase implements AfterViewInit, OnDe get indeterminate(): boolean { return this._indeterminate; } - set indeterminate(indeterminate) { + set indeterminate(indeterminate: BooleanInput) { this._indeterminate = coerceBooleanProperty(indeterminate); this._syncIndeterminate(this._indeterminate); } @@ -143,7 +143,7 @@ export class MatCheckbox extends _MatCheckboxBase implements AfterViewInit, OnDe get required(): boolean { return this._required; } - set required(required) { + set required(required: BooleanInput) { this._required = coerceBooleanProperty(required); } private _required = false; @@ -153,7 +153,7 @@ export class MatCheckbox extends _MatCheckboxBase implements AfterViewInit, OnDe get disableRipple(): boolean { return this._disableRipple; } - set disableRipple(disableRipple: boolean) { + set disableRipple(disableRipple: BooleanInput) { this._disableRipple = coerceBooleanProperty(disableRipple); } private _disableRipple = false; @@ -384,10 +384,4 @@ export class MatCheckbox extends _MatCheckboxBase implements AfterViewInit, OnDe 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 b3ce6c8fa87d..b9544b81b8c6 100644 --- a/src/material-experimental/mdc-chips/chip-grid.ts +++ b/src/material-experimental/mdc-chips/chip-grid.ts @@ -144,7 +144,7 @@ export class MatChipGrid extends _MatChipGridMixinBase implements AfterContentIn 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(); } @@ -172,7 +172,6 @@ export class MatChipGrid extends _MatChipGridMixinBase implements AfterContentIn * @docs-private */ @Input() - @Input() get placeholder(): string { return this._chipInput ? this._chipInput.placeholder : this._placeholder; } @@ -193,7 +192,7 @@ export class MatChipGrid extends _MatChipGridMixinBase implements AfterContentIn 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(); } @@ -521,9 +520,4 @@ export class MatChipGrid extends _MatChipGridMixinBase implements AfterContentIn 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 5b13711057cd..80bcd53bf4bb 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, @@ -199,7 +198,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 0e6b52c98a8c..e68055d6560f 100644 --- a/src/material-experimental/mdc-chips/chip-input.ts +++ b/src/material-experimental/mdc-chips/chip-input.ts @@ -94,7 +94,7 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha */ @Input('matChipInputAddOnBlur') get addOnBlur(): boolean { return this._addOnBlur; } - set addOnBlur(value: boolean) { this._addOnBlur = coerceBooleanProperty(value); } + set addOnBlur(value: BooleanInput) { this._addOnBlur = coerceBooleanProperty(value); } _addOnBlur: boolean = false; /** @@ -119,7 +119,7 @@ export class MatChipInput implements MatChipTextControl, AfterContentInit, OnCha /** Whether the input is disabled. */ @Input() get disabled(): boolean { return this._disabled || (this._chipGrid && this._chipGrid.disabled); } - set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value); } + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled: boolean = false; /** Whether the input is empty. */ @@ -244,7 +244,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 aa7a2678e30c..d3fc97a76897 100644 --- a/src/material-experimental/mdc-chips/chip-listbox.ts +++ b/src/material-experimental/mdc-chips/chip-listbox.ts @@ -115,7 +115,7 @@ export class MatChipListbox extends MatChipSet implements AfterContentInit, Cont /** Whether the user should be allowed to select multiple chips. */ @Input() get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { this._multiple = coerceBooleanProperty(value); this._updateMdcSelectionClasses(); this._syncListboxProperties(); @@ -139,7 +139,7 @@ export class MatChipListbox extends MatChipSet implements AfterContentInit, Cont */ @Input() get selectable(): boolean { return this._selectable; } - set selectable(value: boolean) { + set selectable(value: BooleanInput) { this._selectable = coerceBooleanProperty(value); this._updateMdcSelectionClasses(); this._syncListboxProperties(); @@ -163,7 +163,7 @@ export class MatChipListbox extends MatChipSet implements AfterContentInit, Cont /** Whether this chip listbox is required. */ @Input() get required(): boolean { return this._required; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } protected _required: boolean = false; @@ -548,8 +548,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 dbd3940dda78..2a40ca11ffbf 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; } @@ -234,7 +234,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 a879ee84b09a..213f1c42dcf0 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 { @@ -249,6 +248,4 @@ export class MatChipRow extends MatChip implements AfterContentInit, AfterViewIn 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 f2829f943584..88215b55a620 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, @@ -121,7 +121,7 @@ export class MatChipSet extends _MatChipSetMixinBase implements AfterContentInit /** Whether the chip set is disabled. */ @Input() get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._syncChipsState(); } @@ -333,7 +333,4 @@ export class MatChipSet extends _MatChipSetMixinBase implements AfterContentInit 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 ad88d68962db..8df319eb97a5 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, @@ -155,10 +155,10 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte @Input() 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; @@ -180,7 +180,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte */ @Input() get removable(): boolean { return this._removable; } - set removable(value: boolean) { + set removable(value: BooleanInput) { this._removable = coerceBooleanProperty(value); } protected _removable: boolean = true; @@ -190,7 +190,7 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte */ @Input() get highlighted(): boolean { return this._highlighted; } - set highlighted(value: boolean) { + set highlighted(value: BooleanInput) { this._highlighted = coerceBooleanProperty(value); } protected _highlighted: boolean = false; @@ -446,10 +446,4 @@ export class MatChip extends _MatChipMixinBase implements AfterContentInit, Afte /** 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 a73f11e0d837..ca2676fdc634 100644 --- a/src/material-experimental/mdc-form-field/form-field.ts +++ b/src/material-experimental/mdc-form-field/form-field.ts @@ -160,7 +160,7 @@ export class MatFormField implements AfterViewInit, OnDestroy, AfterContentCheck /** Whether the required marker should be hidden. */ @Input() get hideRequiredMarker(): boolean { return this._hideRequiredMarker; } - set hideRequiredMarker(value: boolean) { + set hideRequiredMarker(value: BooleanInput) { this._hideRequiredMarker = coerceBooleanProperty(value); } private _hideRequiredMarker: boolean; @@ -728,6 +728,4 @@ export class MatFormField implements AfterViewInit, OnDestroy, AfterContentCheck // 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 a43ba7bb0157..34a3479c34e0 100644 --- a/src/material-experimental/mdc-list/list-base.ts +++ b/src/material-experimental/mdc-list/list-base.ts @@ -65,7 +65,7 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri return this.disabled || this._disableRipple || this._listBase.disableRipple || this._noopAnimations; } - set disableRipple(value: boolean) { this._disableRipple = coerceBooleanProperty(value); } + set disableRipple(value: BooleanInput) { this._disableRipple = coerceBooleanProperty(value); } private _disableRipple: boolean = false; /** Whether the list-item is disabled. */ @@ -73,7 +73,7 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri @HostBinding('attr.aria-disabled') @Input() get disabled(): boolean { return this._disabled || (this._listBase && this._listBase.disabled); } - set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value); } + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; private _subscriptions = new Subscription(); @@ -166,9 +166,6 @@ export abstract class MatListItemBase implements AfterContentInit, OnDestroy, Ri })); }); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } @Directive() @@ -180,16 +177,13 @@ export abstract class MatListBase { /** Whether ripples for all list items is disabled. */ @Input() get disableRipple(): boolean { return this._disableRipple; } - set disableRipple(value: boolean) { this._disableRipple = coerceBooleanProperty(value); } + set disableRipple(value: BooleanInput) { this._disableRipple = coerceBooleanProperty(value); } private _disableRipple: boolean = false; /** Whether all list items are disabled. */ @HostBinding('attr.aria-disabled') @Input() get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value); } + 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 7c2031e9891b..117a02dd723e 100644 --- a/src/material-experimental/mdc-list/list-option.ts +++ b/src/material-experimental/mdc-list/list-option.ts @@ -137,7 +137,7 @@ export class MatListOption extends MatListItemBase implements ListOption, OnInit /** Whether the option is selected. */ @Input() 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) { @@ -267,6 +267,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 480561b3d82d..1027249b3220 100644 --- a/src/material-experimental/mdc-list/selection-list.ts +++ b/src/material-experimental/mdc-list/selection-list.ts @@ -99,7 +99,7 @@ export class MatSelectionList extends MatInteractiveListBase /** Whether selection is limited to one or multiple items (default multiple). */ @Input() get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._multiple) { @@ -348,8 +348,6 @@ export class MatSelectionList extends MatInteractiveListBase 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 44638eb7aaea..01c2c36a188c 100644 --- a/src/material-experimental/mdc-progress-spinner/progress-spinner.ts +++ b/src/material-experimental/mdc-progress-spinner/progress-spinner.ts @@ -151,7 +151,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements After 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(); } @@ -164,7 +164,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements After return this._diameter; } - set diameter(size: number) { + set diameter(size: NumberInput) { this._diameter = coerceNumberProperty(size); this._syncFoundation(); } @@ -177,7 +177,7 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements After return this._strokeWidth ?? this.diameter / 10; } - set strokeWidth(value: number) { + set strokeWidth(value: NumberInput) { this._strokeWidth = coerceNumberProperty(value); } @@ -232,10 +232,6 @@ export class MatProgressSpinner extends _MatProgressSpinnerBase implements After 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 1ec2d72939a7..553b92f6fb87 100644 --- a/src/material-experimental/mdc-slide-toggle/slide-toggle.ts +++ b/src/material-experimental/mdc-slide-toggle/slide-toggle.ts @@ -121,7 +121,7 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe /** Tabindex for the input element. */ @Input() get tabIndex(): number { return this._tabIndex; } - set tabIndex(value: number) { + set tabIndex(value: NumberInput) { this._tabIndex = coerceNumberProperty(value); } private _tabIndex: number; @@ -141,12 +141,12 @@ export class MatSlideToggle implements ControlValueAccessor, AfterViewInit, OnDe /** Whether the slide-toggle is required. */ @Input() get required(): boolean { return this._required; } - set required(value) { this._required = coerceBooleanProperty(value); } + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } /** Whether the slide-toggle element is checked or not. */ @Input() get checked(): boolean { return this._checked; } - set checked(value) { + set checked(value: BooleanInput) { this._checked = coerceBooleanProperty(value); if (this._foundation) { @@ -159,7 +159,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; @@ -169,7 +169,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) { @@ -292,10 +292,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 287641d4ad9b..99144453fc59 100644 --- a/src/material-experimental/mdc-slider/slider.ts +++ b/src/material-experimental/mdc-slider/slider.ts @@ -303,7 +303,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 @@ -521,8 +521,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. @@ -566,7 +564,7 @@ export class MatSlider extends _MatSliderMixinBase /** Whether the slider is disabled. */ @Input() get disabled(): boolean { return this._disabled; } - set disabled(v: boolean) { + set disabled(v: BooleanInput) { this._setDisabled(coerceBooleanProperty(v)); this._updateInputsDisabledState(); } @@ -575,19 +573,19 @@ export class MatSlider extends _MatSliderMixinBase /** Whether the slider displays a numeric value label upon pressing the thumb. */ @Input() get discrete(): boolean { return this._discrete; } - set discrete(v: boolean) { this._discrete = coerceBooleanProperty(v); } + set discrete(v: BooleanInput) { this._discrete = coerceBooleanProperty(v); } private _discrete: boolean = false; /** Whether the slider displays tick marks along the slider track. */ @Input() get showTickMarks(): boolean { return this._showTickMarks; } - set showTickMarks(v: boolean) { this._showTickMarks = coerceBooleanProperty(v); } + set showTickMarks(v: BooleanInput) { this._showTickMarks = coerceBooleanProperty(v); } private _showTickMarks: boolean = false; /** The minimum value that the slider can have. */ @Input() get min(): number { return this._min; } - set min(v: number) { + set min(v: NumberInput) { this._min = coerceNumberProperty(v, this._min); this._reinitialize(); } @@ -596,7 +594,7 @@ export class MatSlider extends _MatSliderMixinBase /** The maximum value that the slider can have. */ @Input() get max(): number { return this._max; } - set max(v: number) { + set max(v: NumberInput) { this._max = coerceNumberProperty(v, this._max); this._reinitialize(); } @@ -605,7 +603,7 @@ export class MatSlider extends _MatSliderMixinBase /** The values at which the thumb will snap. */ @Input() get step(): number { return this._step; } - set step(v: number) { + set step(v: NumberInput) { this._step = coerceNumberProperty(v, this._step); this._reinitialize(); } @@ -873,14 +871,6 @@ export class MatSlider extends _MatSliderMixinBase _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 d47df28c5269..b7cf5d9ab418 100644 --- a/src/material-experimental/mdc-tabs/tab-group.ts +++ b/src/material-experimental/mdc-tabs/tab-group.ts @@ -61,7 +61,7 @@ export class MatTabGroup extends _MatTabGroupBase { /** Whether the ink bar should fit its width to the size of the tab label content. */ @Input() get fitInkBarToContent(): boolean { return this._fitInkBarToContent; } - set fitInkBarToContent(v: boolean) { + set fitInkBarToContent(v: BooleanInput) { this._fitInkBarToContent = coerceBooleanProperty(v); this._changeDetectorRef.markForCheck(); } @@ -75,6 +75,4 @@ export class MatTabGroup extends _MatTabGroupBase { this.fitInkBarToContent = defaultConfig && defaultConfig.fitInkBarToContent != null ? 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 5bd22659601a..a84f1b58d556 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, @@ -72,6 +71,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 748fbde25a19..ab39c52ea228 100644 --- a/src/material-experimental/mdc-tabs/tab-label-wrapper.ts +++ b/src/material-experimental/mdc-tabs/tab-label-wrapper.ts @@ -33,7 +33,9 @@ export class MatTabLabelWrapper extends BaseMatTabLabelWrapper /** Whether the ink bar should fit its width to the size of the tab label content. */ @Input() get fitInkBarToContent(): boolean { return this._foundation.getFitToContent(); } - set fitInkBarToContent(v: boolean) { this._foundation.setFitToContent(coerceBooleanProperty(v)); } + set fitInkBarToContent(v: BooleanInput) { + this._foundation.setFitToContent(coerceBooleanProperty(v)); + } constructor(elementRef: ElementRef, @Inject(DOCUMENT) _document: any) { super(elementRef); @@ -48,6 +50,4 @@ export class MatTabLabelWrapper extends BaseMatTabLabelWrapper 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 0f384881b126..2e4062c45175 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 @@ -70,7 +70,7 @@ export class MatTabNav extends _MatTabNavBase implements AfterContentInit { /** Whether the ink bar should fit its width to the size of the tab label content. */ @Input() get fitInkBarToContent(): boolean { return this._fitInkBarToContent.value; } - set fitInkBarToContent(v: boolean) { + set fitInkBarToContent(v: BooleanInput) { this._fitInkBarToContent.next(coerceBooleanProperty(v)); this._changeDetectorRef.markForCheck(); } @@ -102,9 +102,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 1909e074bed0..f827032f8dd6 100644 --- a/src/material/autocomplete/autocomplete-trigger.ts +++ b/src/material/autocomplete/autocomplete-trigger.ts @@ -177,7 +177,7 @@ export abstract class _MatAutocompleteTriggerBase implements ControlValueAccesso */ @Input('matAutocompleteDisabled') get autocompleteDisabled(): boolean { return this._autocompleteDisabled; } - set autocompleteDisabled(value: boolean) { + set autocompleteDisabled(value: BooleanInput) { this._autocompleteDisabled = coerceBooleanProperty(value); } @@ -742,8 +742,6 @@ export abstract class _MatAutocompleteTriggerBase implements ControlValueAccesso } } } - - static ngAcceptInputType_autocompleteDisabled: BooleanInput; } diff --git a/src/material/autocomplete/autocomplete.ts b/src/material/autocomplete/autocomplete.ts index 8e22edb8536c..789094ccf2b3 100644 --- a/src/material/autocomplete/autocomplete.ts +++ b/src/material/autocomplete/autocomplete.ts @@ -143,7 +143,7 @@ export abstract class _MatAutocompleteBase extends _MatAutocompleteMixinBase imp */ @Input() get autoActiveFirstOption(): boolean { return this._autoActiveFirstOption; } - set autoActiveFirstOption(value: boolean) { + set autoActiveFirstOption(value: BooleanInput) { this._autoActiveFirstOption = coerceBooleanProperty(value); } private _autoActiveFirstOption: boolean; @@ -272,9 +272,6 @@ export abstract class _MatAutocompleteBase extends _MatAutocompleteMixinBase imp 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 1e321f7b3340..f5e4704aadba 100644 --- a/src/material/badge/badge.ts +++ b/src/material/badge/badge.ts @@ -72,7 +72,7 @@ export class MatBadge extends _MatBadgeBase implements OnDestroy, OnChanges, Can /** Whether the badge should overlap its contents or not */ @Input('matBadgeOverlap') get overlap(): boolean { return this._overlap; } - set overlap(val: boolean) { + set overlap(val: BooleanInput) { this._overlap = coerceBooleanProperty(val); } private _overlap: boolean = true; @@ -109,7 +109,7 @@ export class MatBadge extends _MatBadgeBase implements OnDestroy, OnChanges, Can /** Whether the badge is hidden. */ @Input('matBadgeHidden') get hidden(): boolean { return this._hidden; } - set hidden(val: boolean) { + set hidden(val: BooleanInput) { this._hidden = coerceBooleanProperty(val); } private _hidden: boolean; @@ -274,8 +274,4 @@ export class MatBadge extends _MatBadgeBase implements OnDestroy, OnChanges, Can const content = this.content; return content == null ? '' : `${content}`; } - - 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 8211689b7edb..21a351a71fb1 100644 --- a/src/material/button-toggle/button-toggle.ts +++ b/src/material/button-toggle/button-toggle.ts @@ -166,7 +166,7 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After /** Whether the toggle group is vertical. */ @Input() get vertical(): boolean { return this._vertical; } - set vertical(value: boolean) { + set vertical(value: BooleanInput) { this._vertical = coerceBooleanProperty(value); } @@ -202,14 +202,14 @@ export class MatButtonToggleGroup implements ControlValueAccessor, OnInit, After /** Whether multiple button toggles can be selected. */ @Input() get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { this._multiple = coerceBooleanProperty(value); } /** Whether multiple button toggle group is disabled. */ @Input() get disabled(): boolean { return this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); if (this._buttonToggles) { @@ -376,10 +376,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. @@ -462,7 +458,7 @@ export class MatButtonToggle extends _MatButtonToggleBase implements OnInit, Aft 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) { @@ -481,7 +477,7 @@ export class MatButtonToggle extends _MatButtonToggleBase implements OnInit, Aft get disabled(): boolean { return this._disabled || (this.buttonToggleGroup && this.buttonToggleGroup.disabled); } - set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value); } + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled: boolean = false; /** Event emitted when the group value changes. */ @@ -572,10 +568,4 @@ export class MatButtonToggle extends _MatButtonToggleBase implements OnInit, Aft // 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 74abd5d24b9d..2b229b343a48 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, @@ -140,9 +139,6 @@ export class MatButton extends _MatButtonBase _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 27e109cc59f1..fe05748061b9 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, @@ -151,7 +151,7 @@ export class MatCheckbox extends _MatCheckboxBase implements ControlValueAccesso /** Whether the checkbox is required. */ @Input() get required(): boolean { return this._required; } - set required(value: boolean) { this._required = coerceBooleanProperty(value); } + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } private _required: boolean; /** Whether the label should appear after or before the checkbox. Defaults to 'after' */ @@ -245,8 +245,8 @@ export class MatCheckbox extends _MatCheckboxBase implements ControlValueAccesso * mixinDisabled, but the mixin is still required because mixinTabIndex requires it. */ @Input() - override get disabled() { return this._disabled; } - override set disabled(value: any) { + override get disabled(): boolean { return this._disabled; } + override set disabled(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this.disabled) { @@ -264,7 +264,7 @@ export class MatCheckbox extends _MatCheckboxBase implements ControlValueAccesso */ @Input() get indeterminate(): boolean { return this._indeterminate; } - set indeterminate(value: boolean) { + set indeterminate(value: BooleanInput) { const changed = value != this._indeterminate; this._indeterminate = coerceBooleanProperty(value); @@ -488,10 +488,4 @@ export class MatCheckbox extends _MatCheckboxBase implements ControlValueAccesso 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 72d74072e629..b70b56bd5f8b 100644 --- a/src/material/chips/chip-input.ts +++ b/src/material/chips/chip-input.ts @@ -88,7 +88,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, A */ @Input('matChipInputAddOnBlur') get addOnBlur(): boolean { return this._addOnBlur; } - set addOnBlur(value: boolean) { this._addOnBlur = coerceBooleanProperty(value); } + set addOnBlur(value: BooleanInput) { this._addOnBlur = coerceBooleanProperty(value); } _addOnBlur: boolean = false; /** @@ -112,7 +112,7 @@ export class MatChipInput implements MatChipTextControl, OnChanges, OnDestroy, A /** Whether the input is disabled. */ @Input() get disabled(): boolean { return this._disabled || (this._chipList && this._chipList.disabled); } - set disabled(value: boolean) { this._disabled = coerceBooleanProperty(value); } + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled: boolean = false; /** Whether the input is empty. */ @@ -230,7 +230,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 de95edc14aee..5b8c69069f48 100644 --- a/src/material/chips/chip-list.ts +++ b/src/material/chips/chip-list.ts @@ -173,7 +173,7 @@ export class MatChipList extends _MatChipListBase implements MatFormFieldControl /** Whether the user should be allowed to select multiple chips. */ @Input() get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { this._multiple = coerceBooleanProperty(value); this._syncChipsState(); } @@ -223,7 +223,7 @@ export class MatChipList extends _MatChipListBase implements MatFormFieldControl 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(); } @@ -268,7 +268,7 @@ export class MatChipList extends _MatChipListBase implements MatFormFieldControl */ @Input() 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(); } @@ -283,7 +283,7 @@ export class MatChipList extends _MatChipListBase implements MatFormFieldControl */ @Input() get selectable(): boolean { return this._selectable; } - set selectable(value: boolean) { + set selectable(value: BooleanInput) { this._selectable = coerceBooleanProperty(value); if (this.chips) { @@ -795,9 +795,4 @@ export class MatChipList extends _MatChipListBase implements MatFormFieldControl }); } } - - 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 235e8b632cbb..5f26cc5bc831 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'; @@ -198,7 +198,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes /** Whether the chip is selected. */ @Input() get selected(): boolean { return this._selected; } - set selected(value: boolean) { + set selected(value: BooleanInput) { const coercedValue = coerceBooleanProperty(value); if (coercedValue !== this._selected) { @@ -226,7 +226,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes */ @Input() get selectable(): boolean { return this._selectable && this.chipListSelectable; } - set selectable(value: boolean) { + set selectable(value: BooleanInput) { this._selectable = coerceBooleanProperty(value); } protected _selectable: boolean = true; @@ -234,7 +234,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes /** Whether the chip is disabled. */ @Input() get disabled(): boolean { return this._chipListDisabled || this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } protected _disabled: boolean = false; @@ -244,7 +244,7 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes */ @Input() get removable(): boolean { return this._removable; } - set removable(value: boolean) { + set removable(value: BooleanInput) { this._removable = coerceBooleanProperty(value); } protected _removable: boolean = true; @@ -431,13 +431,6 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes 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 4e50ce76a2f7..ce515514a23f 100644 --- a/src/material/core/common-behaviors/disable-ripple.ts +++ b/src/material/core/common-behaviors/disable-ripple.ts @@ -25,7 +25,7 @@ export function mixinDisableRipple>(base: T): CanDisab private _disableRipple: boolean = false; /** Whether the ripple effect is disabled or not. */ - get disableRipple() { return this._disableRipple; } + get disableRipple(): boolean { return this._disableRipple; } set disableRipple(value: any) { this._disableRipple = coerceBooleanProperty(value); } constructor(...args: any[]) { super(...args); } diff --git a/src/material/core/common-behaviors/disabled.ts b/src/material/core/common-behaviors/disabled.ts index 9e5679e569b7..864a6a654a41 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() { return this._disabled; } + get disabled(): boolean { return this._disabled; } set disabled(value: any) { this._disabled = coerceBooleanProperty(value); } constructor(...args: any[]) { super(...args); } diff --git a/src/material/core/option/optgroup.ts b/src/material/core/option/optgroup.ts index 3b81ff0ced8e..ce1f6955e847 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, @@ -60,8 +59,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 bdc22e31ba9e..24408b6b71ad 100644 --- a/src/material/core/option/option.ts +++ b/src/material/core/option/option.ts @@ -65,11 +65,11 @@ export class _MatOptionBase implements FocusableOption, AfterViewChecked, OnDest /** Whether the option is disabled. */ @Input() - get disabled() { return (this.group && this.group.disabled) || this._disabled; } - set disabled(value: any) { this._disabled = coerceBooleanProperty(value); } + get disabled(): boolean { return (this.group && this.group.disabled) || this._disabled; } + 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. */ // tslint:disable-next-line:no-output-on-prefix @@ -227,8 +227,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 47c498394884..42eecf6d1793 100644 --- a/src/material/datepicker/date-range-input.ts +++ b/src/material/datepicker/date-range-input.ts @@ -121,7 +121,7 @@ export class MatDateRangeInput implements MatFormFieldControl>, /** Whether the input is required. */ @Input() get required(): boolean { return !!this._required; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } private _required: boolean; @@ -179,7 +179,7 @@ export class MatDateRangeInput implements MatFormFieldControl>, (this._startInput.disabled && this._endInput.disabled) : this._groupDisabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._groupDisabled) { @@ -393,7 +393,4 @@ export class MatDateRangeInput implements MatFormFieldControl>, 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 89c4244f7f01..9fb747ec69ac 100644 --- a/src/material/datepicker/datepicker-base.ts +++ b/src/material/datepicker/datepicker-base.ts @@ -312,7 +312,7 @@ export abstract class MatDatepickerBase, S, */ @Input() get touchUi(): boolean { return this._touchUi; } - set touchUi(value: boolean) { + set touchUi(value: BooleanInput) { this._touchUi = coerceBooleanProperty(value); } private _touchUi = false; @@ -323,7 +323,7 @@ export abstract class MatDatepickerBase, S, return this._disabled === undefined && this.datepickerInput ? this.datepickerInput.disabled : !!this._disabled; } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._disabled) { @@ -348,7 +348,7 @@ export abstract class MatDatepickerBase, S, */ @Input() get restoreFocus(): boolean { return this._restoreFocus; } - set restoreFocus(value: boolean) { + set restoreFocus(value: BooleanInput) { this._restoreFocus = coerceBooleanProperty(value); } private _restoreFocus = true; @@ -394,7 +394,7 @@ export abstract class MatDatepickerBase, S, /** Whether the calendar is open. */ @Input() get opened(): boolean { return this._opened; } - set opened(value: boolean) { + set opened(value: BooleanInput) { coerceBooleanProperty(value) ? this.open() : this.close(); } private _opened = false; @@ -716,9 +716,4 @@ export abstract class MatDatepickerBase, S, })) ); } - - 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 915afbd6713b..063f45d6a972 100644 --- a/src/material/datepicker/datepicker-input-base.ts +++ b/src/material/datepicker/datepicker-input-base.ts @@ -75,7 +75,7 @@ export abstract class MatDatepickerInputBase | undefined; @@ -83,7 +83,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 34c8e9fbc16b..32d8ec33c668 100644 --- a/src/material/datepicker/datepicker-toggle.ts +++ b/src/material/datepicker/datepicker-toggle.ts @@ -77,7 +77,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 7f168ea6c4e1..4cf6cb015aaf 100644 --- a/src/material/divider/divider.ts +++ b/src/material/divider/divider.ts @@ -28,15 +28,12 @@ export class MatDivider { /** Whether the divider is vertically aligned. */ @Input() get vertical(): boolean { return this._vertical; } - set vertical(value: boolean) { this._vertical = coerceBooleanProperty(value); } + set vertical(value: BooleanInput) { this._vertical = coerceBooleanProperty(value); } private _vertical: boolean = false; /** Whether the divider is an inset divider. */ @Input() get inset(): boolean { return this._inset; } - set inset(value: boolean) { this._inset = coerceBooleanProperty(value); } + 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 942b7a3353ce..1d2e41e89cfa 100644 --- a/src/material/expansion/accordion.ts +++ b/src/material/expansion/accordion.ts @@ -58,7 +58,7 @@ export class MatAccordion extends CdkAccordion implements MatAccordionBase, /** Whether the expansion indicator should be hidden. */ @Input() get hideToggle(): boolean { return this._hideToggle; } - set hideToggle(show: boolean) { this._hideToggle = coerceBooleanProperty(show); } + set hideToggle(show: BooleanInput) { this._hideToggle = coerceBooleanProperty(show); } private _hideToggle: boolean = false; /** @@ -98,6 +98,4 @@ export class MatAccordion extends CdkAccordion implements MatAccordionBase, 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 553cc7b73fcc..b802c70f0954 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'; @@ -225,8 +224,6 @@ export class MatExpansionPanelHeader extends _MatExpansionPanelHeaderMixinBase i 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 b328cdedcd08..e8b828541af9 100644 --- a/src/material/expansion/expansion-panel.ts +++ b/src/material/expansion/expansion-panel.ts @@ -106,7 +106,7 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI get hideToggle(): boolean { return this._hideToggle || (this.accordion && this.accordion.hideToggle); } - set hideToggle(value: boolean) { + set hideToggle(value: BooleanInput) { this._hideToggle = coerceBooleanProperty(value); } @@ -238,8 +238,6 @@ export class MatExpansionPanel extends CdkAccordionItem implements AfterContentI 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 8c361cc02a2e..a758265c9919 100644 --- a/src/material/form-field/form-field.ts +++ b/src/material/form-field/form-field.ts @@ -178,7 +178,7 @@ export class MatFormField extends _MatFormFieldBase /** Whether the required marker should be hidden. */ @Input() get hideRequiredMarker(): boolean { return this._hideRequiredMarker; } - set hideRequiredMarker(value: boolean) { + set hideRequiredMarker(value: BooleanInput) { this._hideRequiredMarker = coerceBooleanProperty(value); } private _hideRequiredMarker: boolean; @@ -607,6 +607,4 @@ export class MatFormField extends _MatFormFieldBase // 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 3bbe08b67167..407ea72b363c 100644 --- a/src/material/grid-list/grid-list.ts +++ b/src/material/grid-list/grid-list.ts @@ -86,7 +86,7 @@ export class MatGridList implements MatGridListBase, OnInit, AfterContentChecked /** Amount of columns in the grid list. */ @Input() get cols(): number { return this._cols; } - set cols(value: number) { + set cols(value: NumberInput) { this._cols = Math.max(1, Math.round(coerceNumberProperty(value))); } @@ -178,6 +178,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 486a15441a8a..a6c0f09cd71b 100644 --- a/src/material/grid-list/grid-tile.ts +++ b/src/material/grid-list/grid-tile.ts @@ -49,12 +49,12 @@ export class MatGridTile { /** Amount of rows that the grid tile takes up. */ @Input() get rowspan(): number { return this._rowspan; } - set rowspan(value: number) { this._rowspan = Math.round(coerceNumberProperty(value)); } + set rowspan(value: NumberInput) { this._rowspan = Math.round(coerceNumberProperty(value)); } /** Amount of columns that the grid tile takes up. */ @Input() get colspan(): number { return this._colspan; } - set colspan(value: number) { this._colspan = Math.round(coerceNumberProperty(value)); } + set colspan(value: NumberInput) { this._colspan = Math.round(coerceNumberProperty(value)); } /** * Sets the style of the grid-tile element. Needs to be set manually to avoid @@ -63,9 +63,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 2cd2ac9f4b16..bd685e17da0b 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; @@ -433,6 +433,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 527fa03d3902..5ee0a0cccd45 100644 --- a/src/material/input/input.ts +++ b/src/material/input/input.ts @@ -142,7 +142,7 @@ export class MatInput extends _MatInputBase implements MatFormFieldControl, } 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. @@ -175,7 +175,7 @@ export class MatInput extends _MatInputBase implements MatFormFieldControl, */ @Input() get required(): boolean { return this._required; } - set required(value: boolean) { this._required = coerceBooleanProperty(value); } + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } protected _required = false; /** Input type of the element. */ @@ -209,7 +209,7 @@ export class MatInput extends _MatInputBase implements MatFormFieldControl, */ @Input() 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(); @@ -219,7 +219,7 @@ export class MatInput extends _MatInputBase implements MatFormFieldControl, /** Whether the element is readonly. */ @Input() get readonly(): boolean { return this._readonly; } - set readonly(value: boolean) { this._readonly = coerceBooleanProperty(value); } + set readonly(value: BooleanInput) { this._readonly = coerceBooleanProperty(value); } private _readonly = false; protected _neverEmptyInputTypes = [ @@ -471,12 +471,4 @@ export class MatInput extends _MatInputBase implements MatFormFieldControl, this.focus(); } } - - 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 6e6927dca5b9..f823cb9bcf0a 100644 --- a/src/material/list/list.ts +++ b/src/material/list/list.ts @@ -84,9 +84,6 @@ export class MatNavList extends _MatListBase implements CanDisable, CanDisableRi ngOnDestroy() { this._stateChanges.complete(); } - - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } @Component({ @@ -136,9 +133,6 @@ export class MatList extends _MatListBase implements CanDisable, CanDisableRippl ngOnDestroy() { this._stateChanges.complete(); } - - static ngAcceptInputType_disableRipple: BooleanInput; - static ngAcceptInputType_disabled: BooleanInput; } /** @@ -224,8 +218,8 @@ export class MatListItem extends _MatListItemMixinBase implements AfterContentIn /** Whether the option is disabled. */ @Input() - get disabled() { return this._disabled || !!(this._list && this._list.disabled); } - set disabled(value: boolean) { + get disabled(): boolean { return this._disabled || !!(this._list && this._list.disabled); } + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; @@ -249,7 +243,4 @@ export class MatListItem extends _MatListItemMixinBase implements AfterContentIn _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 c3310355c713..4c5d85cb576f 100644 --- a/src/material/list/selection-list.ts +++ b/src/material/list/selection-list.ts @@ -170,8 +170,10 @@ export class MatListOption extends _MatListOptionBase implements AfterContentIni /** Whether the option is disabled. */ @Input() - get disabled() { return this._disabled || (this.selectionList && this.selectionList.disabled); } - set disabled(value: any) { + get disabled(): boolean { + return this._disabled || (this.selectionList && this.selectionList.disabled); + } + set disabled(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._disabled) { @@ -183,7 +185,7 @@ export class MatListOption extends _MatListOptionBase implements AfterContentIni /** Whether the option is selected. */ @Input() 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) { @@ -321,10 +323,6 @@ export class MatListOption extends _MatListOptionBase implements AfterContentIni _markForCheck() { this._changeDetector.markForCheck(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_selected: BooleanInput; - static ngAcceptInputType_disableRipple: BooleanInput; } @@ -383,7 +381,7 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl /** Whether the selection list is disabled. */ @Input() 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 @@ -397,7 +395,7 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl /** Whether selection is limited to one or multiple items (default multiple). */ @Input() get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { const newValue = coerceBooleanProperty(value); if (newValue !== this._multiple) { @@ -738,8 +736,4 @@ export class MatSelectionList extends _MatSelectionListBase implements CanDisabl 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 b21b7a04af43..bb00c0da17a0 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, @@ -187,7 +186,4 @@ export class MatMenuItem extends _MatMenuItemBase 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 85a1d9a034f6..211ce8a13016 100644 --- a/src/material/menu/menu.ts +++ b/src/material/menu/menu.ts @@ -187,7 +187,7 @@ export class _MatMenuBase implements AfterContentInit, MatMenuPanel /** Whether the menu should overlap its trigger. */ @Input() get overlapTrigger(): boolean { return this._overlapTrigger; } - set overlapTrigger(value: boolean) { + set overlapTrigger(value: BooleanInput) { this._overlapTrigger = coerceBooleanProperty(value); } private _overlapTrigger: boolean = this._defaultOptions.overlapTrigger; @@ -195,7 +195,7 @@ export class _MatMenuBase implements AfterContentInit, MatMenuPanel /** Whether the menu has a backdrop. */ @Input() 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; @@ -477,9 +477,6 @@ export class _MatMenuBase implements AfterContentInit, MatMenuPanel 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 265c7fdfa520..7cc7f8a0974f 100644 --- a/src/material/paginator/paginator.ts +++ b/src/material/paginator/paginator.ts @@ -110,7 +110,7 @@ export abstract class _MatPaginatorBase implemen /** Whether the radio group is disabled */ @Input() get disabled(): boolean { return this._disabled; } - set disabled(value) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); this._markRadiosForCheck(); } @@ -210,7 +209,7 @@ export abstract class _MatRadioGroupBase implemen /** Whether the radio group is required */ @Input() get required(): boolean { return this._required; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); this._markRadiosForCheck(); } @@ -311,9 +310,6 @@ export abstract class _MatRadioGroupBase implemen this.disabled = isDisabled; this._changeDetector.markForCheck(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_required: BooleanInput; } /** @@ -376,7 +372,7 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple /** Whether this radio button is checked. */ @Input() 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; @@ -430,7 +426,7 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple get disabled(): boolean { return this._disabled || (this.radioGroup !== null && this.radioGroup.disabled); } - set disabled(value: boolean) { + set disabled(value: BooleanInput) { this._setDisabled(coerceBooleanProperty(value)); } @@ -439,7 +435,7 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple get required(): boolean { return this._required || (this.radioGroup && this.radioGroup.required); } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } @@ -613,12 +609,6 @@ export abstract class _MatRadioButtonBase extends _MatRadioButtonMixinBase imple 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 ecd4a4db7916..9822fcdd8186 100644 --- a/src/material/select/select.ts +++ b/src/material/select/select.ts @@ -318,7 +318,7 @@ export abstract class _MatSelectBase extends _MatSelectMixinBase implements A /** Whether the component is required. */ @Input() get required(): boolean { return this._required; } - set required(value: boolean) { + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); this.stateChanges.next(); } @@ -327,7 +327,7 @@ export abstract class _MatSelectBase extends _MatSelectMixinBase implements A /** Whether the user should be allowed to select multiple options. */ @Input() get multiple(): boolean { return this._multiple; } - set multiple(value: boolean) { + set multiple(value: BooleanInput) { if (this._selectionModel && (typeof ngDevMode === 'undefined' || ngDevMode)) { throw getMatSelectDynamicMultipleError(); } @@ -339,7 +339,7 @@ export abstract class _MatSelectBase extends _MatSelectMixinBase implements A /** Whether to center the active option over the trigger. */ @Input() get disableOptionCentering(): boolean { return this._disableOptionCentering; } - set disableOptionCentering(value: boolean) { + set disableOptionCentering(value: BooleanInput) { this._disableOptionCentering = coerceBooleanProperty(value); } private _disableOptionCentering = this._defaultOptions?.disableOptionCentering ?? false; @@ -389,7 +389,7 @@ export abstract class _MatSelectBase extends _MatSelectMixinBase implements A /** Time to wait in milliseconds after the last keystroke before moving focus to an item. */ @Input() get typeaheadDebounceInterval(): number { return this._typeaheadDebounceInterval; } - set typeaheadDebounceInterval(value: number) { + set typeaheadDebounceInterval(value: NumberInput) { this._typeaheadDebounceInterval = coerceNumberProperty(value); } private _typeaheadDebounceInterval: number; @@ -1053,14 +1053,6 @@ export abstract class _MatSelectBase extends _MatSelectMixinBase implements A 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 c3bfd8260e3b..de7bd3d97f70 100644 --- a/src/material/sidenav/drawer.ts +++ b/src/material/sidenav/drawer.ts @@ -179,7 +179,7 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr /** Whether the drawer can be closed with the escape key or by clicking on the backdrop. */ @Input() get disableClose(): boolean { return this._disableClose; } - set disableClose(value: boolean) { this._disableClose = coerceBooleanProperty(value); } + set disableClose(value: BooleanInput) { this._disableClose = coerceBooleanProperty(value); } private _disableClose: boolean = false; /** @@ -205,11 +205,11 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr } return value; } - set autoFocus(value: AutoFocusTarget | string | boolean) { - if (value === 'true' || value === 'false') { - value = coerceBooleanProperty(value); - } - this._autoFocus = value; + set autoFocus(value: AutoFocusTarget | string | BooleanInput) { + if (value === 'true' || value === 'false' || value == null) { + value = coerceBooleanProperty(value); + } + this._autoFocus = value; } private _autoFocus: AutoFocusTarget | string | boolean | undefined; @@ -219,7 +219,7 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr */ @Input() get opened(): boolean { return this._opened; } - set opened(value: boolean) { this.toggle(coerceBooleanProperty(value)); } + set opened(value: BooleanInput) { this.toggle(coerceBooleanProperty(value)); } private _opened: boolean = false; /** How the sidenav was opened (keypress, mouse click etc.) */ @@ -550,10 +550,6 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr _animationDoneListener(event: AnimationEvent) { this._animationEnd.next(event); } - - static ngAcceptInputType_disableClose: BooleanInput; - static ngAcceptInputType_autoFocus: AutoFocusTarget | string | BooleanInput; - static ngAcceptInputType_opened: BooleanInput; } @@ -610,7 +606,7 @@ export class MatDrawerContainer implements AfterContentInit, DoCheck, OnDestroy */ @Input() get autosize(): boolean { return this._autosize; } - set autosize(value: boolean) { this._autosize = coerceBooleanProperty(value); } + set autosize(value: BooleanInput) { this._autosize = coerceBooleanProperty(value); } private _autosize: boolean; /** @@ -619,14 +615,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; @@ -932,7 +928,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 1b52390d0095..5db21488c36a 100644 --- a/src/material/sidenav/sidenav.ts +++ b/src/material/sidenav/sidenav.ts @@ -80,7 +80,7 @@ export class MatSidenav extends MatDrawer { /** Whether the sidenav is fixed in the viewport. */ @Input() get fixedInViewport(): boolean { return this._fixedInViewport; } - set fixedInViewport(value) { this._fixedInViewport = coerceBooleanProperty(value); } + set fixedInViewport(value: BooleanInput) { this._fixedInViewport = coerceBooleanProperty(value); } private _fixedInViewport = false; /** @@ -89,7 +89,7 @@ export class MatSidenav extends MatDrawer { */ @Input() get fixedTopGap(): number { return this._fixedTopGap; } - set fixedTopGap(value) { this._fixedTopGap = coerceNumberProperty(value); } + set fixedTopGap(value: NumberInput) { this._fixedTopGap = coerceNumberProperty(value); } private _fixedTopGap = 0; /** @@ -98,12 +98,8 @@ export class MatSidenav extends MatDrawer { */ @Input() get fixedBottomGap(): number { return this._fixedBottomGap; } - set fixedBottomGap(value) { this._fixedBottomGap = coerceNumberProperty(value); } + set fixedBottomGap(value: NumberInput) { this._fixedBottomGap = coerceNumberProperty(value); } private _fixedBottomGap = 0; - - static ngAcceptInputType_fixedInViewport: BooleanInput; - static ngAcceptInputType_fixedTopGap: NumberInput; - static ngAcceptInputType_fixedBottomGap: NumberInput; } diff --git a/src/material/slide-toggle/slide-toggle.ts b/src/material/slide-toggle/slide-toggle.ts index 6a411f17aeea..8fe1da365910 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, @@ -133,12 +133,12 @@ export class MatSlideToggle extends _MatSlideToggleBase implements OnDestroy, Af /** Whether the slide-toggle is required. */ @Input() get required(): boolean { return this._required; } - set required(value) { this._required = coerceBooleanProperty(value); } + set required(value: BooleanInput) { this._required = coerceBooleanProperty(value); } /** Whether the slide-toggle element is checked or not. */ @Input() get checked(): boolean { return this._checked; } - set checked(value) { + set checked(value: BooleanInput) { this._checked = coerceBooleanProperty(value); this._changeDetectorRef.markForCheck(); } @@ -286,10 +286,4 @@ export class MatSlideToggle extends _MatSlideToggleBase implements OnDestroy, Af // 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 f83afac1cca5..3ef81e7e6fb4 100644 --- a/src/material/slider/slider.ts +++ b/src/material/slider/slider.ts @@ -159,7 +159,7 @@ export class MatSlider extends _MatSliderBase /** Whether the slider is inverted. */ @Input() get invert(): boolean { return this._invert; } - set invert(value: boolean) { + set invert(value: BooleanInput) { this._invert = coerceBooleanProperty(value); } private _invert = false; @@ -167,7 +167,7 @@ export class MatSlider extends _MatSliderBase /** The maximum value that the slider can have. */ @Input() 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); @@ -179,7 +179,7 @@ export class MatSlider extends _MatSliderBase /** The minimum value that the slider can have. */ @Input() 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); @@ -191,7 +191,7 @@ export class MatSlider extends _MatSliderBase /** The values at which the thumb will snap. */ @Input() 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) { @@ -206,7 +206,7 @@ export class MatSlider extends _MatSliderBase /** Whether or not to show the thumb label. */ @Input() get thumbLabel(): boolean { return this._thumbLabel; } - set thumbLabel(value: boolean) { this._thumbLabel = coerceBooleanProperty(value); } + set thumbLabel(value: BooleanInput) { this._thumbLabel = coerceBooleanProperty(value); } private _thumbLabel: boolean = false; /** @@ -214,8 +214,8 @@ export class MatSlider extends _MatSliderBase * Ex: Tick interval of 4 with a step of 3 will draw a tick every 4 steps (every 12 values). */ @Input() - get tickInterval() { return this._tickInterval; } - set tickInterval(value: 'auto' | number) { + get tickInterval(): 'auto' | number { return this._tickInterval; } + set tickInterval(value: 'auto' | NumberInput) { if (value === 'auto') { this._tickInterval = 'auto'; } else if (typeof value === 'number' || typeof value === 'string') { @@ -235,7 +235,7 @@ export class MatSlider extends _MatSliderBase } return this._value as number; } - set value(v: number) { + set value(v: NumberInput) { if (v !== this._value) { let value = coerceNumberProperty(v, 0); @@ -267,7 +267,7 @@ export class MatSlider extends _MatSliderBase /** Whether the slider is vertical. */ @Input() get vertical(): boolean { return this._vertical; } - set vertical(value: boolean) { + set vertical(value: BooleanInput) { this._vertical = coerceBooleanProperty(value); } private _vertical = false; @@ -910,17 +910,6 @@ export class MatSlider extends _MatSliderBase 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 3bfdc01ac647..66358b9a39c3 100644 --- a/src/material/sort/sort-header.ts +++ b/src/material/sort/sort-header.ts @@ -135,7 +135,7 @@ export class MatSortHeader extends _MatSortHeaderBase /** Overrides the disable clear value of the containing MatSort for this MatSortable. */ @Input() get disableClear(): boolean { return this._disableClear; } - set disableClear(v) { this._disableClear = coerceBooleanProperty(v); } + set disableClear(v: BooleanInput) { this._disableClear = coerceBooleanProperty(v); } private _disableClear: boolean; constructor( @@ -335,7 +335,4 @@ export class MatSortHeader extends _MatSortHeaderBase 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 aa8323f94f61..960b258c9e66 100644 --- a/src/material/sort/sort.ts +++ b/src/material/sort/sort.ts @@ -111,7 +111,7 @@ export class MatSort extends _MatSortBase */ @Input('matSortDisableClear') get disableClear(): boolean { return this._disableClear; } - set disableClear(v: boolean) { this._disableClear = coerceBooleanProperty(v); } + set disableClear(v: BooleanInput) { this._disableClear = coerceBooleanProperty(v); } private _disableClear: boolean; /** Event emitted when the user changes either the active sort or sort direction. */ @@ -186,9 +186,6 @@ export class MatSort extends _MatSortBase 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 946dc06fa239..7861c9018e96 100644 --- a/src/material/tabs/paginated-tab-header.ts +++ b/src/material/tabs/paginated-tab-header.ts @@ -123,7 +123,7 @@ export abstract class MatPaginatedTabHeader implements AfterContentChecked, Afte /** The index of the active tab. */ get selectedIndex(): number { return this._selectedIndex; } - set selectedIndex(value: number) { + set selectedIndex(value: NumberInput) { value = coerceNumberProperty(value); if (this._selectedIndex != value) { @@ -585,6 +585,4 @@ export abstract class MatPaginatedTabHeader implements AfterContentChecked, Afte 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 e719fca94dd7..ffeb0fa7eefc 100644 --- a/src/material/tabs/tab-group.ts +++ b/src/material/tabs/tab-group.ts @@ -105,13 +105,13 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements /** Whether the tab group should grow to the size of the active tab. */ @Input() get dynamicHeight(): boolean { return this._dynamicHeight; } - set dynamicHeight(value: boolean) { this._dynamicHeight = coerceBooleanProperty(value); } + set dynamicHeight(value: BooleanInput) { this._dynamicHeight = coerceBooleanProperty(value); } private _dynamicHeight: boolean; /** The index of the active tab. */ @Input() 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,7 +135,7 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements */ @Input() 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; @@ -415,12 +415,6 @@ export abstract class _MatTabGroupBase extends _MatTabGroupMixinBase implements 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 ac4664015f6f..62c9503bb246 100644 --- a/src/material/tabs/tab-header.ts +++ b/src/material/tabs/tab-header.ts @@ -44,8 +44,8 @@ export abstract class _MatTabHeaderBase extends MatPaginatedTabHeader implements /** Whether the ripple effect is disabled or not. */ @Input() - get disableRipple() { return this._disableRipple; } - set disableRipple(value: any) { this._disableRipple = coerceBooleanProperty(value); } + get disableRipple(): boolean { return this._disableRipple; } + set disableRipple(value: BooleanInput) { this._disableRipple = coerceBooleanProperty(value); } private _disableRipple: boolean = false; constructor(elementRef: ElementRef, @@ -102,6 +102,4 @@ export class MatTabHeader extends _MatTabHeaderBase { @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) { 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 ba33ae622494..869e2b106d85 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'; @@ -44,6 +43,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 832239903323..41583405903c 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 { @@ -77,8 +77,8 @@ export abstract class _MatTabNavBase extends MatPaginatedTabHeader implements Af /** Whether the ripple effect is disabled or not. */ @Input() - get disableRipple() { return this._disableRipple; } - set disableRipple(value: any) { this._disableRipple = coerceBooleanProperty(value); } + get disableRipple(): boolean { return this._disableRipple; } + set disableRipple(value: BooleanInput) { this._disableRipple = coerceBooleanProperty(value); } private _disableRipple: boolean = false; /** Theme color of the nav bar. */ @@ -170,8 +170,6 @@ export class MatTabNav extends _MatTabNavBase { @Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode?: string) { super(elementRef, dir, ngZone, changeDetectorRef, viewportRuler, platform, animationMode); } - - static ngAcceptInputType_disableRipple: BooleanInput; } // Boilerplate for applying mixins to MatTabLink. @@ -188,11 +186,11 @@ export class _MatTabLinkBase extends _MatTabLinkMixinBase implements AfterViewIn /** Whether the link is active. */ @Input() 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(); } } @@ -248,11 +246,6 @@ export class _MatTabLinkBase extends _MatTabLinkMixinBase implements AfterViewIn // 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 775842436b16..085b5eea39e7 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, @@ -143,6 +142,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 3685dd0b0285..a58691a33ee5 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 { @@ -168,7 +173,7 @@ export abstract class _MatTooltipBase implement /** Disables the display of the tooltip. */ @Input('matTooltipDisabled') get disabled(): boolean { return this._disabled; } - set disabled(value) { + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); // If tooltip is disabled, hide immediately. @@ -180,10 +185,20 @@ export abstract class _MatTooltipBase implement } /** 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 @@ -716,10 +731,6 @@ export abstract class _MatTooltipBase implement style.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 04e78b32304e..1666b942fd26 100644 --- a/src/material/tree/node.ts +++ b/src/material/tree/node.ts @@ -29,7 +29,7 @@ import { 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)); @@ -72,9 +72,6 @@ export class MatTreeNode extends _MatTreeNodeBase override ngOnDestroy() { super.ngOnDestroy(); } - - static ngAcceptInputType_disabled: BooleanInput; - static ngAcceptInputType_tabIndex: NumberInput; } /** @@ -111,8 +108,8 @@ export class MatNestedTreeNode extends CdkNestedTreeNode /** Whether the node is disabled. */ @Input() - get disabled() { return this._disabled; } - set disabled(value: any) { this._disabled = coerceBooleanProperty(value); } + get disabled(): boolean { return this._disabled; } + set disabled(value: BooleanInput) { this._disabled = coerceBooleanProperty(value); } private _disabled = false; /** Tabindex for the node. */ @@ -155,6 +152,4 @@ export class MatNestedTreeNode extends CdkNestedTreeNode override ngOnDestroy() { super.ngOnDestroy(); } - - static ngAcceptInputType_disabled: BooleanInput; } diff --git a/src/material/tree/padding.ts b/src/material/tree/padding.ts index 9312b49ca93e..4032f2f541f3 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'; @@ -20,7 +21,7 @@ export class MatTreeNodePadding extends CdkTreeNodePadding { /** The level of depth of the tree node. The padding will be `level * indent` pixels. */ @Input('matTreeNodePadding') override get level(): number { return this._level; } - override set level(value: number) { this._setLevelInput(value); } + override set level(value: NumberInput) { this._setLevelInput(value); } /** The indent for each level. Default number 40px from material design menu sub-menu spec. */ @Input('matTreeNodePaddingIndent') diff --git a/tools/dgeni/common/private-docs.ts b/tools/dgeni/common/private-docs.ts index faf5eb43940e..5adcc81376ae 100644 --- a/tools/dgeni/common/private-docs.ts +++ b/tools/dgeni/common/private-docs.ts @@ -39,8 +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 0832a015225f..3e138ba9a2c3 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 9a02c8e27ce0..32cb81c41601 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 e5731456d2ca..6b67d34d35f6 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 c2eca5fbc46d..3b24c0b3f9a2 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; @@ -319,7 +311,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[]; @@ -328,15 +320,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 e03cc9afda5e..33d59b5f9194 100644 --- a/tools/public_api_guard/cdk/tree.md +++ b/tools/public_api_guard/cdk/tree.md @@ -198,16 +198,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) @@ -219,10 +217,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 8c2ac67f7583..a95dda7775e4 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 dc728879f0ea..d29e9defea62 100644 --- a/tools/public_api_guard/material/badge.md +++ b/tools/public_api_guard/material/badge.md @@ -31,22 +31,16 @@ export class MatBadge extends _MatBadgeBase implements OnDestroy, OnChanges, Can getBadgeElement(): HTMLElement | undefined; _hasContent: boolean; 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) ngOnChanges(changes: SimpleChanges): void; // (undocumented) ngOnDestroy(): 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 ef0f51e59746..e9fc11ccb697 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 696bc0271994..53f2c3946c2e 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/common-behaviors/constructor'; 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 63891a537908..7edd0f19a8c5 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 d630f0e0fba3..392de69b17aa 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 c14027952212..3aab4a6dcd8d 100644 --- a/tools/public_api_guard/material/core.md +++ b/tools/public_api_guard/material/core.md @@ -255,8 +255,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; }]>; @@ -276,9 +274,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; @@ -290,8 +288,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 da6a7b6ef509..74ad8f821d0d 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 b0ee666fae7c..17a01104799c 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 b7e9b03e87b3..50f0b1731d87 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 c9a1b60da8a0..cfa077580294 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 c6268b78b75d..7cb754c2ff15 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) @@ -67,14 +67,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; @@ -91,9 +83,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; setDescribedByIds(ids: string[]): void; @@ -108,7 +100,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 c5a22401f69f..6c7229958046 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 0667b186b12a..3e4e1dca1fb7 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 a1e5c27746e3..033c110a1d9e 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 e24b692b70b1..581fa3449344 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 8d6b27bc30a5..bd28144ba46e 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 4800224ae4ce..3e4b9aff6744 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 0f82f1c55c4f..b509ae5df713 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 b1cf9df053e6..02428e964720 100644 --- a/tools/public_api_guard/material/sidenav.md +++ b/tools/public_api_guard/material/sidenav.md @@ -58,7 +58,7 @@ export class MatDrawer implements AfterContentInit, AfterContentChecked, OnDestr _animationStartListener(event: AnimationEvent_2): void; _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; @@ -66,19 +66,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; @@ -87,7 +81,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; @@ -110,7 +104,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; @@ -130,15 +124,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; @@ -180,17 +170,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 06718daeebc0..3d077b42548e 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 cc1ff42ea2fb..2e3660910e36 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 7b293e52886e..6c36c146f6de 100644 --- a/tools/public_api_guard/material/sort.md +++ b/tools/public_api_guard/material/sort.md @@ -57,13 +57,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; @@ -112,7 +108,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; @@ -128,10 +124,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 c7e52a211b57..c934973f1fdc 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; @@ -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; @@ -304,8 +290,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) @@ -339,8 +325,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; @@ -362,21 +346,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; @@ -398,8 +374,6 @@ export class MatTabNav extends _MatTabNavBase { // (undocumented) _nextPaginator: ElementRef; // (undocumented) - static ngAcceptInputType_disableRipple: BooleanInput; - // (undocumented) _previousPaginator: ElementRef; // (undocumented) _tabList: ElementRef; @@ -417,8 +391,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 27fcc780331f..7efddaa8a0f4 100644 --- a/tools/public_api_guard/material/tree.md +++ b/tools/public_api_guard/material/tree.md @@ -36,10 +36,8 @@ import { ViewContainerRef } from '@angular/core'; // @public export class MatNestedTreeNode extends CdkNestedTreeNode implements AfterContentInit, DoCheck, 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) @@ -123,10 +121,6 @@ export class MatTreeNestedDataSource extends DataSource { export class MatTreeNode extends _MatTreeNodeBase implements CanDisable, DoCheck, HasTabIndex, OnInit, OnDestroy { constructor(elementRef: ElementRef, tree: CdkTree, tabIndex: string); // (undocumented) - static ngAcceptInputType_disabled: BooleanInput; - // (undocumented) - static ngAcceptInputType_tabIndex: NumberInput; - // (undocumented) ngDoCheck(): void; // (undocumented) ngOnDestroy(): void; @@ -166,7 +160,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 e61187d91c72..000000000000 --- a/tools/tslint-rules/coercionTypesRule.ts +++ /dev/null @@ -1,269 +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..d553b2c24efa --- /dev/null +++ b/tools/tslint-rules/noCoercionMembersRule.ts @@ -0,0 +1,22 @@ +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 29697ebe06b5..68b3bf235eee 100644 --- a/tslint.json +++ b/tslint.json @@ -144,14 +144,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", diff --git a/yarn.lock b/yarn.lock index 617d3b50796b..a673df981b44 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13576,11 +13576,6 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -"typescript-4.2@npm:typescript@4.2.3": - version "4.2.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.3.tgz#39062d8019912d43726298f09493d598048c1ce3" - integrity sha512-qOcYwxaByStAWrBf4x0fibwZvMRG+r4cQoTjbPtUlrWjBHbmCAww1i448U0GJ+3cNNEtebDteo/cHOR3xJ4wEw== - typescript@4.3.2, typescript@^3.2.2: version "4.3.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.2.tgz#399ab18aac45802d6f2498de5054fcbbe716a805"