Skip to content

feat: expand input types with coercion to work with ngtsc input type checking #17528

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
merged 5 commits into from
Oct 31, 2019
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
2 changes: 1 addition & 1 deletion src/a11y-demo/datepicker/datepicker-a11y.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ export class DatepickerAccessibilityDemo {
appointmentDate: Date;
minAppointmentDate = new Date();
maxAppointmentDate = new Date(Date.now() + 365 * 24 * 60 * 60 * 1000);
weekdaysOnly = (d: Date) => d.getDay() != 0 && d.getDay() != 6;
weekdaysOnly = (d: Date|null) => d !== null && d.getDay() != 0 && d.getDay() != 6;
}
1 change: 0 additions & 1 deletion src/cdk-experimental/dialog/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk-experimental/dialog",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk-experimental/popover-edit/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk-experimental/popover-edit",
"skipTemplateCodegen": true,
Expand Down
3 changes: 3 additions & 0 deletions src/cdk-experimental/scrolling/auto-size-virtual-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,7 @@ export class CdkAutoSizeVirtualScroll implements OnChanges {
ngOnChanges() {
this._scrollStrategy.updateBufferSize(this.minBufferPx, this.maxBufferPx);
}

static ngAcceptInputType_minBufferPx: number | string;
static ngAcceptInputType_maxBufferPx: number | string;
}
1 change: 0 additions & 1 deletion src/cdk-experimental/scrolling/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk-experimental/scrolling",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk-experimental/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"angularCompilerOptions": {
"enableIvy": false,
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk-experimental",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk-experimental/tsconfig-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
}
},
"angularCompilerOptions": {
"strictMetadataEmit": true,
"skipTemplateCodegen": true,
"emitDecoratorMetadata": true,

Expand Down
3 changes: 3 additions & 0 deletions src/cdk/a11y/focus-trap/focus-trap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,4 +418,7 @@ export class CdkTrapFocus implements OnDestroy, AfterContentInit, DoCheck {
this.focusTrap.attachAnchors();
}
}

static ngAcceptInputType_enabled: boolean | string;
static ngAcceptInputType_autoCapture: boolean | string;
}
1 change: 0 additions & 1 deletion src/cdk/a11y/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/a11y",
"skipTemplateCodegen": true,
Expand Down
3 changes: 3 additions & 0 deletions src/cdk/accordion/accordion-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,7 @@ export class CdkAccordionItem implements OnDestroy {
}
});
}

static ngAcceptInputType_expanded: boolean | string;
static ngAcceptInputType_disabled: boolean | string;
}
2 changes: 2 additions & 0 deletions src/cdk/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ export class CdkAccordion implements OnDestroy, OnChanges {
this._openCloseAllActions.next(expanded);
}
}

static ngAcceptInputType_multi: boolean | string;
}
1 change: 0 additions & 1 deletion src/cdk/accordion/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/accordion",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk/bidi/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/bidi",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk/clipboard/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/clipboard",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk/coercion/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/coercion",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk/collections/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/collections",
"skipTemplateCodegen": true,
Expand Down
2 changes: 2 additions & 0 deletions src/cdk/drag-drop/directives/drag-handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ export class CdkDragHandle implements OnDestroy {
ngOnDestroy() {
this._stateChanges.complete();
}

static ngAcceptInputType_disabled: boolean | string;
}
2 changes: 2 additions & 0 deletions src/cdk/drag-drop/directives/drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ export class CdkDrag<T = any> implements AfterViewInit, OnChanges, OnDestroy {
});
});
}

static ngAcceptInputType_disabled: boolean | string;
}

/** Gets the closest ancestor of an element that matches a selector. */
Expand Down
2 changes: 2 additions & 0 deletions src/cdk/drag-drop/directives/drop-list-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ export class CdkDropListGroup<T> implements OnDestroy {
ngOnDestroy() {
this._items.clear();
}

static ngAcceptInputType_disabled: boolean | string;
}
3 changes: 3 additions & 0 deletions src/cdk/drag-drop/directives/drop-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,7 @@ export class CdkDropList<T = any> implements AfterContentInit, OnDestroy {
});
}

static ngAcceptInputType_disabled: boolean | string;
static ngAcceptInputType_sortingDisabled: boolean | string;
static ngAcceptInputType_autoScrollDisabled: boolean | string;
}
1 change: 0 additions & 1 deletion src/cdk/drag-drop/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/drag-drop",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk/keycodes/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/keycodes",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk/layout/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/layout",
"skipTemplateCodegen": true,
Expand Down
3 changes: 3 additions & 0 deletions src/cdk/observers/observe-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ export class CdkObserveContent implements AfterContentInit, OnDestroy {
this._currentSubscription.unsubscribe();
}
}

static ngAcceptInputType_disabled: boolean | string;
static ngAcceptInputType_debounce: boolean | string;
}


Expand Down
1 change: 0 additions & 1 deletion src/cdk/observers/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/observers",
"skipTemplateCodegen": true,
Expand Down
6 changes: 6 additions & 0 deletions src/cdk/overlay/overlay-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ export class CdkConnectedOverlay implements OnDestroy, OnChanges {

this._backdropSubscription.unsubscribe();
}

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


Expand Down
1 change: 0 additions & 1 deletion src/cdk/overlay/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/overlay",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk/platform/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/platform",
"skipTemplateCodegen": true,
Expand Down
2 changes: 2 additions & 0 deletions src/cdk/portal/portal-directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ export class CdkPortalOutlet extends BasePortalOutlet implements OnInit, OnDestr

return viewRef;
}

static ngAcceptInputType_portal: Portal<any> | null | undefined | '';
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/cdk/portal/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/portal",
"skipTemplateCodegen": true,
Expand Down
4 changes: 4 additions & 0 deletions src/cdk/scrolling/fixed-size-virtual-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,8 @@ export class CdkFixedSizeVirtualScroll implements OnChanges {
ngOnChanges() {
this._scrollStrategy.updateItemAndBufferSize(this.itemSize, this.minBufferPx, this.maxBufferPx);
}

static ngAcceptInputType_itemSize: string | number;
static ngAcceptInputType_minBufferPx: string | number;
static ngAcceptInputType_maxBufferPx: string | number;
}
1 change: 0 additions & 1 deletion src/cdk/scrolling/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/scrolling",
"skipTemplateCodegen": true,
Expand Down
12 changes: 12 additions & 0 deletions src/cdk/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ export class CdkStep implements OnChanges {
// underlying MatStepHeader, we have to make sure that change detection runs correctly.
this._stepper._stateChanged();
}

static ngAcceptInputType_editable: boolean | string;
static ngAcceptInputType_hasError: boolean | string;
static ngAcceptInputType_optional: boolean | string;
static ngAcceptInputType_completed: boolean | string;
}

@Directive({
Expand Down Expand Up @@ -519,6 +524,13 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
const focusedElement = this._document.activeElement;
return stepperElement === focusedElement || stepperElement.contains(focusedElement);
}

static ngAcceptInputType_editable: boolean | string;
static ngAcceptInputType_optional: boolean | string;
static ngAcceptInputType_completed: boolean | string;
static ngAcceptInputType_hasError: boolean | string;
static ngAcceptInputType_linear: boolean | string;
static ngAcceptInputType_selectedIndex: number | string;
}


Expand Down
1 change: 0 additions & 1 deletion src/cdk/stepper/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/stepper",
"skipTemplateCodegen": true,
Expand Down
3 changes: 3 additions & 0 deletions src/cdk/table/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ export class CdkColumnDef extends _CdkColumnDefBase implements CanStick {
* do not match are replaced by the '-' character.
*/
cssClassFriendlyName: string;

static ngAcceptInputType_sticky: boolean | string;
static ngAcceptInputType_stickyEnd: boolean | string;
}

/** Base class for the cells. Adds a CSS classname that identifies the column it renders in. */
Expand Down
4 changes: 4 additions & 0 deletions src/cdk/table/row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export class CdkHeaderRowDef extends _CdkHeaderRowDefBase implements CanStick, O
ngOnChanges(changes: SimpleChanges): void {
super.ngOnChanges(changes);
}

static ngAcceptInputType_sticky: boolean | string;
}

// Boilerplate for applying mixins to CdkFooterRowDef.
Expand All @@ -125,6 +127,8 @@ export class CdkFooterRowDef extends _CdkFooterRowDefBase implements CanStick, O
ngOnChanges(changes: SimpleChanges): void {
super.ngOnChanges(changes);
}

static ngAcceptInputType_sticky: boolean | string;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/cdk/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,8 @@ export class CdkTable<T> implements AfterContentChecked, CollectionViewer, OnDes
this.updateStickyColumnStyles();
});
}

static ngAcceptInputType_multiTemplateDataRows: boolean | string;
}

/** Utility function that gets a merged list of the entries in a QueryList and values of a Set. */
Expand Down
1 change: 0 additions & 1 deletion src/cdk/table/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/table",
"skipTemplateCodegen": true,
Expand Down
1 change: 0 additions & 1 deletion src/cdk/testing/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/testing",
"skipTemplateCodegen": true,
Expand Down
10 changes: 7 additions & 3 deletions src/cdk/text-field/autosize.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 {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';
import {
Directive,
ElementRef,
Expand Down Expand Up @@ -56,15 +56,15 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
@Input('cdkAutosizeMinRows')
get minRows(): number { return this._minRows; }
set minRows(value: number) {
this._minRows = value;
this._minRows = coerceNumberProperty(value);
this._setMinHeight();
}

/** Maximum amount of rows in the textarea. */
@Input('cdkAutosizeMaxRows')
get maxRows(): number { return this._maxRows; }
set maxRows(value: number) {
this._maxRows = value;
this._maxRows = coerceNumberProperty(value);
this._setMaxHeight();
}

Expand Down Expand Up @@ -272,4 +272,8 @@ export class CdkTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {
textarea.setSelectionRange(selectionStart, selectionEnd);
}
}

static ngAcceptInputType_minRows: number | string;
static ngAcceptInputType_maxRows: number | string;
static ngAcceptInputType_enabled: boolean | string;
}
1 change: 0 additions & 1 deletion src/cdk/text-field/tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
],
"angularCompilerOptions": {
"annotateForClosureCompiler": true,
"strictMetadataEmit": true,
"flatModuleOutFile": "index.js",
"flatModuleId": "@angular/cdk/text-field",
"skipTemplateCodegen": true,
Expand Down
2 changes: 2 additions & 0 deletions src/cdk/tree/padding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,6 @@ export class CdkTreeNodePadding<T> implements OnDestroy {
this._currentPadding = padding;
}
}

static ngAcceptInputType_level: number | string;
}
Loading