Skip to content

refactor: switch acceptance members to type aliases #17653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {coerceNumberProperty} from '@angular/cdk/coercion';
import {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';
import {ListRange} from '@angular/cdk/collections';
import {
CdkVirtualScrollViewport,
Expand Down Expand Up @@ -464,6 +464,6 @@ export class CdkAutoSizeVirtualScroll implements OnChanges {
this._scrollStrategy.updateBufferSize(this.minBufferPx, this.maxBufferPx);
}

static ngAcceptInputType_minBufferPx: number | string | null | undefined;
static ngAcceptInputType_maxBufferPx: number | string | null | undefined;
static ngAcceptInputType_minBufferPx: NumberInput;
static ngAcceptInputType_maxBufferPx: NumberInput;
}
6 changes: 3 additions & 3 deletions src/cdk/a11y/focus-trap/focus-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
import {DOCUMENT} from '@angular/common';
import {
AfterContentInit,
Expand Down Expand Up @@ -419,6 +419,6 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit, DoCheck {
}
}

static ngAcceptInputType_enabled: boolean | string | null | undefined;
static ngAcceptInputType_autoCapture: boolean | string | null | undefined;
static ngAcceptInputType_enabled: BooleanInput;
static ngAcceptInputType_autoCapture: BooleanInput;
}
6 changes: 3 additions & 3 deletions src/cdk/accordion/accordion-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@angular/core';
import {UniqueSelectionDispatcher} from '@angular/cdk/collections';
import {CdkAccordion} from './accordion';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
import {Subscription} from 'rxjs';

/** Used to generate unique ID for each accordion item. */
Expand Down Expand Up @@ -153,6 +153,6 @@ export class CdkAccordionItem implements OnDestroy {
});
}

static ngAcceptInputType_expanded: boolean | string | null | undefined;
static ngAcceptInputType_disabled: boolean | string | null | undefined;
static ngAcceptInputType_expanded: BooleanInput;
static ngAcceptInputType_disabled: BooleanInput;
}
4 changes: 2 additions & 2 deletions src/cdk/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
import {Directive, Input, OnChanges, OnDestroy, SimpleChanges} from '@angular/core';
import {Subject} from 'rxjs';

Expand Down Expand Up @@ -60,5 +60,5 @@ export class CdkAccordion implements OnDestroy, OnChanges {
}
}

static ngAcceptInputType_multi: boolean | string | null | undefined;
static ngAcceptInputType_multi: BooleanInput;
}
6 changes: 6 additions & 0 deletions src/cdk/coercion/boolean-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/

/**
* Type describing the allowed values for a boolean input.
* @docs-private
*/
export type BooleanInput = string | boolean | null | undefined;

/** Coerces a data-bound value (typically a string) to a boolean. */
export function coerceBooleanProperty(value: any): boolean {
return value != null && `${value}` !== 'false';
Expand Down
6 changes: 6 additions & 0 deletions src/cdk/coercion/number-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/

/**
* Type describing the allowed values for a number input
* @docs-private
*/
export type NumberInput = string | number | null | undefined;

/** Coerces a data-bound value (typically a string) to a number. */
export function coerceNumberProperty(value: any): number;
export function coerceNumberProperty<D>(value: any, fallback: D): number | D;
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/drag-drop/directives/drag-handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {Directive, ElementRef, Inject, Optional, Input, OnDestroy} from '@angular/core';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
import {Subject} from 'rxjs';
import {CDK_DRAG_PARENT} from '../drag-parent';
import {toggleNativeDragInteractions} from '../drag-styling';
Expand Down Expand Up @@ -47,5 +47,5 @@ export class CdkDragHandle implements OnDestroy {
this._stateChanges.complete();
}

static ngAcceptInputType_disabled: boolean | string | null | undefined;
static ngAcceptInputType_disabled: BooleanInput;
}
9 changes: 7 additions & 2 deletions src/cdk/drag-drop/directives/drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ import {
ChangeDetectorRef,
isDevMode,
} from '@angular/core';
import {coerceBooleanProperty, coerceNumberProperty, coerceElement} from '@angular/cdk/coercion';
import {
coerceBooleanProperty,
coerceNumberProperty,
coerceElement,
BooleanInput
} from '@angular/cdk/coercion';
import {Observable, Observer, Subject, merge} from 'rxjs';
import {startWith, take, map, takeUntil, switchMap, tap} from 'rxjs/operators';
import {
Expand Down Expand Up @@ -409,7 +414,7 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
});
}

static ngAcceptInputType_disabled: boolean | string | null | undefined;
static ngAcceptInputType_disabled: BooleanInput;
}

/** Gets the closest ancestor of an element that matches a selector. */
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/drag-drop/directives/drop-list-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {Directive, OnDestroy, Input} from '@angular/core';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';

/**
* Declaratively connects sibling `cdkDropList` instances together. All of the `cdkDropList`
Expand Down Expand Up @@ -35,5 +35,5 @@ export class CdkDropListGroup<T> implements OnDestroy {
this._items.clear();
}

static ngAcceptInputType_disabled: boolean | string | null | undefined;
static ngAcceptInputType_disabled: BooleanInput;
}
8 changes: 4 additions & 4 deletions src/cdk/drag-drop/directives/drop-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {coerceArray, coerceBooleanProperty} from '@angular/cdk/coercion';
import {BooleanInput, coerceArray, coerceBooleanProperty} from '@angular/cdk/coercion';
import {
ContentChildren,
ElementRef,
Expand Down Expand Up @@ -332,7 +332,7 @@ export class CdkDropList<T = any> implements AfterContentInit, OnDestroy {
});
}

static ngAcceptInputType_disabled: boolean | string | null | undefined;
static ngAcceptInputType_sortingDisabled: boolean | string | null | undefined;
static ngAcceptInputType_autoScrollDisabled: boolean | string | null | undefined;
static ngAcceptInputType_disabled: BooleanInput;
static ngAcceptInputType_sortingDisabled: BooleanInput;
static ngAcceptInputType_autoScrollDisabled: BooleanInput;
}
11 changes: 8 additions & 3 deletions src/cdk/observers/observe-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/

import {coerceBooleanProperty, coerceNumberProperty, coerceElement} from '@angular/cdk/coercion';
import {
coerceBooleanProperty,
coerceNumberProperty,
coerceElement,
BooleanInput
} from '@angular/cdk/coercion';
import {
AfterContentInit,
Directive,
Expand Down Expand Up @@ -194,8 +199,8 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy {
}
}

static ngAcceptInputType_disabled: boolean | string | null | undefined;
static ngAcceptInputType_debounce: boolean | string | null | undefined;
static ngAcceptInputType_disabled: BooleanInput;
static ngAcceptInputType_debounce: BooleanInput;
}


Expand Down
12 changes: 6 additions & 6 deletions src/cdk/overlay/overlay-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {Direction, Directionality} from '@angular/cdk/bidi';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
import {ESCAPE, hasModifierKey} from '@angular/cdk/keycodes';
import {TemplatePortal} from '@angular/cdk/portal';
import {
Expand Down Expand Up @@ -395,11 +395,11 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {
this._backdropSubscription.unsubscribe();
}

static ngAcceptInputType_hasBackdrop: boolean | string | null | undefined;
static ngAcceptInputType_lockPosition: boolean | string | null | undefined;
static ngAcceptInputType_flexibleDimensions: boolean | string | null | undefined;
static ngAcceptInputType_growAfterOpen: boolean | string | null | undefined;
static ngAcceptInputType_push: boolean | string | null | undefined;
static ngAcceptInputType_hasBackdrop: BooleanInput;
static ngAcceptInputType_lockPosition: BooleanInput;
static ngAcceptInputType_flexibleDimensions: BooleanInput;
static ngAcceptInputType_growAfterOpen: BooleanInput;
static ngAcceptInputType_push: BooleanInput;
}


Expand Down
8 changes: 4 additions & 4 deletions src/cdk/scrolling/fixed-size-virtual-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {coerceNumberProperty} from '@angular/cdk/coercion';
import {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';
import {Directive, forwardRef, Input, OnChanges} from '@angular/core';
import {Observable, Subject} from 'rxjs';
import {distinctUntilChanged} from 'rxjs/operators';
Expand Down Expand Up @@ -204,7 +204,7 @@ export class CdkFixedSizeVirtualScroll implements OnChanges {
this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx);
}

static ngAcceptInputType_itemSize: string | number | null | undefined;
static ngAcceptInputType_minBufferPx: string | number | null | undefined;
static ngAcceptInputType_maxBufferPx: string | number | null | undefined;
static ngAcceptInputType_itemSize: NumberInput;
static ngAcceptInputType_minBufferPx: NumberInput;
static ngAcceptInputType_maxBufferPx: NumberInput;
}
27 changes: 16 additions & 11 deletions src/cdk/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

import {FocusableOption, FocusKeyManager} from '@angular/cdk/a11y';
import {Direction, Directionality} from '@angular/cdk/bidi';
import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';
import {
BooleanInput,
coerceBooleanProperty,
coerceNumberProperty,
NumberInput
} from '@angular/cdk/coercion';
import {END, ENTER, hasModifierKey, HOME, SPACE} from '@angular/cdk/keycodes';
import {DOCUMENT} from '@angular/common';
import {
Expand Down Expand Up @@ -231,10 +236,10 @@ export class CdkStep implements OnChanges {
this._stepper._stateChanged();
}

static ngAcceptInputType_editable: boolean | string | null | undefined;
static ngAcceptInputType_hasError: boolean | string | null | undefined;
static ngAcceptInputType_optional: boolean | string | null | undefined;
static ngAcceptInputType_completed: boolean | string | null | undefined;
static ngAcceptInputType_editable: BooleanInput;
static ngAcceptInputType_hasError: BooleanInput;
static ngAcceptInputType_optional: BooleanInput;
static ngAcceptInputType_completed: BooleanInput;
}

@Directive({
Expand Down Expand Up @@ -518,12 +523,12 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
return stepperElement === focusedElement || stepperElement.contains(focusedElement);
}

static ngAcceptInputType_editable: boolean | string | null | undefined;
static ngAcceptInputType_optional: boolean | string | null | undefined;
static ngAcceptInputType_completed: boolean | string | null | undefined;
static ngAcceptInputType_hasError: boolean | string | null | undefined;
static ngAcceptInputType_linear: boolean | string | null | undefined;
static ngAcceptInputType_selectedIndex: number | string | null | undefined;
static ngAcceptInputType_editable: BooleanInput;
static ngAcceptInputType_optional: BooleanInput;
static ngAcceptInputType_completed: BooleanInput;
static ngAcceptInputType_hasError: BooleanInput;
static ngAcceptInputType_linear: BooleanInput;
static ngAcceptInputType_selectedIndex: NumberInput;
}


Expand Down
6 changes: 3 additions & 3 deletions src/cdk/table/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
import {ContentChild, Directive, ElementRef, Input, TemplateRef} from '@angular/core';
import {CanStick, CanStickCtor, mixinHasStickyInput} from './can-stick';

Expand Down Expand Up @@ -108,8 +108,8 @@ export class CdkColumnDef extends _CdkColumnDefBase implements CanStick {
*/
cssClassFriendlyName: string;

static ngAcceptInputType_sticky: boolean | string | null | undefined;
static ngAcceptInputType_stickyEnd: boolean | string | null | undefined;
static ngAcceptInputType_sticky: BooleanInput;
static ngAcceptInputType_stickyEnd: BooleanInput;
}

/** Base class for the cells. Adds a CSS classname that identifies the column it renders in. */
Expand Down
5 changes: 3 additions & 2 deletions src/cdk/table/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/

import {BooleanInput} from '@angular/cdk/coercion';
import {
ChangeDetectionStrategy,
Component,
Expand Down Expand Up @@ -100,7 +101,7 @@ export class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick, O
super.ngOnChanges(changes);
}

static ngAcceptInputType_sticky: boolean | string | null | undefined;
static ngAcceptInputType_sticky: BooleanInput;
}

// Boilerplate for applying mixins to CdkFooterRowDef.
Expand Down Expand Up @@ -128,7 +129,7 @@ export class CdkFooterRowDef extends _CdkFooterRowDefBase implements CanStick, O
super.ngOnChanges(changes);
}

static ngAcceptInputType_sticky: boolean | string | null | undefined;
static ngAcceptInputType_sticky: BooleanInput;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {Direction, Directionality} from '@angular/cdk/bidi';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {BooleanInput, coerceBooleanProperty} from '@angular/cdk/coercion';
import {CollectionViewer, DataSource, isDataSource} from '@angular/cdk/collections';
import {Platform} from '@angular/cdk/platform';
import {DOCUMENT} from '@angular/common';
Expand Down Expand Up @@ -1077,7 +1077,7 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
});
}

static ngAcceptInputType_multiTemplateDataRows: boolean | string | null | undefined;
static ngAcceptInputType_multiTemplateDataRows: BooleanInput;
}

/** Utility function that gets a merged list of the entries in a QueryList and values of a Set. */
Expand Down
13 changes: 9 additions & 4 deletions src/cdk/text-field/autosize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
* found in the LICENSE file at https://angular.io/license
*/

import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';
import {
BooleanInput,
coerceBooleanProperty,
coerceNumberProperty,
NumberInput
} from '@angular/cdk/coercion';
import {
Directive,
ElementRef,
Expand Down Expand Up @@ -281,7 +286,7 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
}
}

static ngAcceptInputType_minRows: number | string | null | undefined;
static ngAcceptInputType_maxRows: number | string | null | undefined;
static ngAcceptInputType_enabled: boolean | string | null | undefined;
static ngAcceptInputType_minRows: NumberInput;
static ngAcceptInputType_maxRows: NumberInput;
static ngAcceptInputType_enabled: BooleanInput;
}
4 changes: 2 additions & 2 deletions src/cdk/tree/padding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import {Directionality} from '@angular/cdk/bidi';
import {coerceNumberProperty} from '@angular/cdk/coercion';
import {coerceNumberProperty, NumberInput} from '@angular/cdk/coercion';
import {Directive, ElementRef, Input, OnDestroy, Optional, Renderer2} from '@angular/core';
import {takeUntil} from 'rxjs/operators';
import {Subject} from 'rxjs';
Expand Down Expand Up @@ -110,5 +110,5 @@ export class CdkTreeNodePadding<T> implements OnDestroy {
}
}

static ngAcceptInputType_level: number | string | null | undefined;
static ngAcceptInputType_level: NumberInput;
}
Loading