Skip to content

chore(docs): add types to public and jsdoc cleanup #7711

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 11 commits into from
Jan 22, 2018
8 changes: 4 additions & 4 deletions src/cdk/accordion/accordion-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ let nextId = 0;
})
export class CdkAccordionItem implements OnDestroy {
/** Event emitted every time the AccordionItem is closed. */
@Output() closed = new EventEmitter<void>();
@Output() closed: EventEmitter<void> = new EventEmitter<void>();
/** Event emitted every time the AccordionItem is opened. */
@Output() opened = new EventEmitter<void>();
@Output() opened: EventEmitter<void> = new EventEmitter<void>();
/** Event emitted when the AccordionItem is destroyed. */
@Output() destroyed = new EventEmitter<void>();
@Output() destroyed: EventEmitter<void> = new EventEmitter<void>();
/** The unique AccordionItem id. */
readonly id = `cdk-accordion-child-${nextId++}`;
readonly id: string = `cdk-accordion-child-${nextId++}`;

/** Whether the AccordionItem is expanded. */
@Input()
Expand Down
5 changes: 3 additions & 2 deletions src/cdk/stepper/stepper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,14 @@ export class CdkStepper implements OnDestroy {

/** The step that is selected. */
@Input()
get selected() { return this._steps.toArray()[this.selectedIndex]; }
get selected(): CdkStep { return this._steps.toArray()[this.selectedIndex]; }
set selected(step: CdkStep) {
this.selectedIndex = this._steps.toArray().indexOf(step);
}

/** Event emitted when the selected step has changed. */
@Output() selectionChange = new EventEmitter<StepperSelectionEvent>();
@Output() selectionChange: EventEmitter<StepperSelectionEvent>
= new EventEmitter<StepperSelectionEvent>();

/** The index of the step that the focus can be set. */
_focusIndex: number = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class CdkTable<T> implements CollectionViewer, OnInit, AfterContentChecke
* Stream containing the latest information on what rows are being displayed on screen.
* Can be used by the data source to as a heuristic of what data should be provided.
*/
viewChange =
viewChange: BehaviorSubject<{start: number, end: number}> =
new BehaviorSubject<{start: number, end: number}>({start: 0, end: Number.MAX_VALUE});

// Placeholders within the table's template where the header and data rows will be inserted.
Expand Down
4 changes: 2 additions & 2 deletions src/lib/button-toggle/button-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class MatButtonToggleGroup extends _MatButtonToggleGroupMixinBase
return this._vertical;
}

set vertical(value) {
set vertical(value: boolean) {
this._vertical = coerceBooleanProperty(value);
}

Expand All @@ -141,7 +141,7 @@ export class MatButtonToggleGroup extends _MatButtonToggleGroupMixinBase

/** Whether the toggle group is selected. */
@Input()
get selected() {
get selected(): MatButtonToggle | null {
return this._selected;
}

Expand Down
6 changes: 3 additions & 3 deletions src/lib/chips/chip-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class MatChipInput {
* Whether or not the chipEnd event will be emitted when the input is blurred.
*/
@Input('matChipInputAddOnBlur')
get addOnBlur() { return this._addOnBlur; }
get addOnBlur(): boolean { return this._addOnBlur; }
set addOnBlur(value: boolean) { this._addOnBlur = coerceBooleanProperty(value); }
_addOnBlur: boolean = false;

Expand All @@ -67,7 +67,7 @@ export class MatChipInput {

/** Emitted when a chip is to be added. */
@Output('matChipInputTokenEnd')
chipEnd = new EventEmitter<MatChipInputEvent>();
chipEnd: EventEmitter<MatChipInputEvent> = new EventEmitter<MatChipInputEvent>();

/** The input's placeholder text. */
@Input() placeholder: string = '';
Expand Down Expand Up @@ -127,5 +127,5 @@ export class MatChipInput {
this._chipList.stateChanges.next();
}

focus() { this._inputElement.focus(); }
focus(): void { this._inputElement.focus(); }
}
19 changes: 12 additions & 7 deletions src/lib/chips/chip-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
this._id = value;
this.stateChanges.next();
}
get id() { return this._id || this._uid; }
get id(): string { return this._id || this._uid; }

/** Required for FormFieldControl. Whether the chip list is required. */
@Input()
set required(value: any) {
set required(value: boolean) {
this._required = coerceBooleanProperty(value);
this.stateChanges.next();
}
get required() {
get required(): boolean {
return this._required;
}

Expand All @@ -245,7 +245,7 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
this._placeholder = value;
this.stateChanges.next();
}
get placeholder() {
get placeholder(): string {
return this._chipInput ? this._chipInput.placeholder : this._placeholder;
}

Expand All @@ -260,6 +260,7 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
return (!this._chipInput || this._chipInput.empty) && this.chips.length === 0;
}

/** @docs-private */
get shouldLabelFloat(): boolean {
return !this.empty || this.focused;
}
Expand Down Expand Up @@ -315,7 +316,7 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
* to facilitate the two-way binding for the `value` input.
* @docs-private
*/
@Output() valueChange = new EventEmitter<any>();
@Output() valueChange: EventEmitter<any> = new EventEmitter<any>();

/** The chip components contained within this chip list. */
@ContentChildren(MatChip) chips: QueryList<MatChip>;
Expand Down Expand Up @@ -389,7 +390,10 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
this._chipInput = inputElement;
}

// Implemented as part of MatFormFieldControl.
/**
* Implemented as part of MatFormFieldControl.
* @docs-private
*/
setDescribedByIds(ids: string[]) { this._ariaDescribedby = ids.join(' '); }

// Implemented as part of ControlValueAccessor
Expand All @@ -416,6 +420,7 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
this.stateChanges.next();
}

/** @docs-private */
onContainerClick() {
this.focus();
}
Expand All @@ -424,7 +429,7 @@ export class MatChipList extends _MatChipListMixinBase implements MatFormFieldCo
* Focuses the the first non-disabled chip in this chip list, or the associated input when there
* are no eligible chips.
*/
focus() {
focus(): void {
// TODO: ARIA says this should focus the first `selected` chip if any are selected.
// Focus on first element if there's no chipInput inside chip-list
if (this._chipInput && this._chipInput.focused) {
Expand Down
9 changes: 5 additions & 4 deletions src/lib/chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes
_onBlur = new Subject<MatChipEvent>();

/** Emitted when the chip is selected or deselected. */
@Output() selectionChange = new EventEmitter<MatChipSelectionChange>();
@Output() selectionChange: EventEmitter<MatChipSelectionChange>
= new EventEmitter<MatChipSelectionChange>();

/** Emitted when the chip is destroyed. */
@Output() destroyed = new EventEmitter<MatChipEvent>();
Expand All @@ -160,16 +161,16 @@ export class MatChip extends _MatChipMixinBase implements FocusableOption, OnDes
* Emitted when the chip is destroyed.
* @deprecated Use 'destroyed' instead.
*/
@Output() destroy = this.destroyed;
@Output() destroy: EventEmitter<MatChipEvent> = this.destroyed;

/** Emitted when a chip is to be removed. */
@Output() removed = new EventEmitter<MatChipEvent>();
@Output() removed: EventEmitter<MatChipEvent> = new EventEmitter<MatChipEvent>();

/**
* Emitted when a chip is to be removed.
* @deprecated Use `removed` instead.
*/
@Output('remove') onRemove = this.removed;
@Output('remove') onRemove: EventEmitter<MatChipEvent> = this.removed;

get ariaSelected(): string | null {
return this.selectable ? this.selected.toString() : null;
Expand Down
11 changes: 7 additions & 4 deletions src/lib/datepicker/datepicker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ export class MatDatepickerInput<D> implements AfterContentInit, ControlValueAcce

/** Whether the datepicker-input is disabled. */
@Input()
get disabled() { return !!this._disabled; }
set disabled(value: any) {
get disabled(): boolean { return !!this._disabled; }
set disabled(value: boolean) {
const newValue = coerceBooleanProperty(value);

if (this._disabled !== newValue) {
Expand All @@ -167,10 +167,12 @@ export class MatDatepickerInput<D> implements AfterContentInit, ControlValueAcce
private _disabled: boolean;

/** Emits when a `change` event is fired on this `<input>`. */
@Output() dateChange = new EventEmitter<MatDatepickerInputEvent<D>>();
@Output() dateChange: EventEmitter<MatDatepickerInputEvent<D>>
= new EventEmitter<MatDatepickerInputEvent<D>>();

/** Emits when an `input` event is fired on this `<input>`. */
@Output() dateInput = new EventEmitter<MatDatepickerInputEvent<D>>();
@Output() dateInput: EventEmitter<MatDatepickerInputEvent<D>>
= new EventEmitter<MatDatepickerInputEvent<D>>();

/** Emits when the value changes (either due to user input or programmatic change). */
_valueChange = new EventEmitter<D|null>();
Expand Down Expand Up @@ -263,6 +265,7 @@ export class MatDatepickerInput<D> implements AfterContentInit, ControlValueAcce
this._disabledChange.complete();
}

/** @docs-private */
registerOnValidatorChange(fn: () => void): void {
this._validatorOnChange = fn;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class MatDatepicker<D> implements OnDestroy {
* Emits new selected date when selected date changes.
* @deprecated Switch to the `dateChange` and `dateInput` binding on the input element.
*/
@Output() selectedChanged = new EventEmitter<D>();
@Output() selectedChanged: EventEmitter<D> = new EventEmitter<D>();

/** Classes to be passed to the date picker panel. Supports the same syntax as `ngClass`. */
@Input() panelClass: string | string[];
Expand All @@ -181,7 +181,7 @@ export class MatDatepicker<D> implements OnDestroy {
private _opened = false;

/** The id for the datepicker calendar. */
id = `mat-datepicker-${datepickerUid++}`;
id: string = `mat-datepicker-${datepickerUid++}`;

/** The currently selected date. */
get _selected(): D | null { return this._validSelected; }
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dialog/dialog-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class MatDialogRef<T, R = any> {
componentInstance: T;

/** Whether the user is allowed to close the dialog. */
disableClose = this._containerInstance._config.disableClose;
disableClose: boolean | undefined = this._containerInstance._config.disableClose;

/** Subject for notifying the user that the dialog has finished opening. */
private _afterOpen = new Subject<void>();
Expand Down
8 changes: 3 additions & 5 deletions src/lib/expansion/expansion-panel-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ import {matExpansionAnimations} from './expansion-animations';


/**
* <mat-expansion-panel-header> component.
* <mat-expansion-panel-header>
*
* This component corresponds to the header element of an <mat-expansion-panel>.
*
* Please refer to README.md for examples on how to use it.
*/
@Component({
moduleId: module.id,
Expand Down Expand Up @@ -139,7 +137,7 @@ export class MatExpansionPanelHeader implements OnDestroy {
}

/**
* <mat-panel-description> directive.
* <mat-panel-description>
*
* This direction is to be used inside of the MatExpansionPanelHeader component.
*/
Expand All @@ -152,7 +150,7 @@ export class MatExpansionPanelHeader implements OnDestroy {
export class MatExpansionPanelDescription {}

/**
* <mat-panel-title> directive.
* <mat-panel-title>
*
* This direction is to be used inside of the MatExpansionPanelHeader component.
*/
Expand Down
6 changes: 2 additions & 4 deletions src/lib/expansion/expansion-panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ export const _MatExpansionPanelMixinBase = mixinDisabled(MatExpansionPanelBase);
export type MatExpansionPanelState = 'expanded' | 'collapsed';

/**
* <mat-expansion-panel> component.
* <mat-expansion-panel>
*
* This component can be used as a single element to show expandable content, or as one of
* multiple children of an element with the MatAccordion directive attached.
*
* Please refer to README.md for examples on how to use it.
* multiple children of an element with the MdAccordion directive attached.
*/
@Component({
moduleId: module.id,
Expand Down
10 changes: 5 additions & 5 deletions src/lib/form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ export class MatFormField implements AfterViewInit, AfterContentInit, AfterConte

/** Whether the required marker should be hidden. */
@Input()
get hideRequiredMarker() { return this._hideRequiredMarker; }
set hideRequiredMarker(value: any) {
get hideRequiredMarker(): boolean { return this._hideRequiredMarker; }
set hideRequiredMarker(value: boolean) {
this._hideRequiredMarker = coerceBooleanProperty(value);
}
private _hideRequiredMarker: boolean;
Expand All @@ -118,7 +118,7 @@ export class MatFormField implements AfterViewInit, AfterContentInit, AfterConte

/** Text for the form field hint. */
@Input()
get hintLabel() { return this._hintLabel; }
get hintLabel(): string { return this._hintLabel; }
set hintLabel(value: string) {
this._hintLabel = value;
this._processHints();
Expand All @@ -133,12 +133,12 @@ export class MatFormField implements AfterViewInit, AfterContentInit, AfterConte
* @deprecated Use floatLabel instead.
*/
@Input()
get floatPlaceholder() { return this._floatLabel; }
get floatPlaceholder(): FloatLabelType { return this._floatLabel; }
set floatPlaceholder(value: FloatLabelType) { this.floatLabel = value; }

/** Whether the label should always float, never float or float as the user types. */
@Input()
get floatLabel() { return this._floatLabel; }
get floatLabel(): FloatLabelType { return this._floatLabel; }
set floatLabel(value: FloatLabelType) {
if (value !== this._floatLabel) {
this._floatLabel = value || this._labelOptions.float || 'auto';
Expand Down
8 changes: 4 additions & 4 deletions src/lib/grid-list/grid-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ export class MatGridList implements OnInit, AfterContentChecked {

/** Amount of columns in the grid list. */
@Input()
get cols() { return this._cols; }
set cols(value: any) { this._cols = coerceToNumber(value); }
get cols(): number { return this._cols; }
set cols(value: number) { this._cols = coerceToNumber(value); }

/** Size of the grid list's gutter in pixels. */
@Input()
get gutterSize() { return this._gutter; }
set gutterSize(value: any) { this._gutter = coerceToString(value); }
get gutterSize(): string { return this._gutter; }
set gutterSize(value: string) { this._gutter = coerceToString(value); }

/** Set internal representation of row height from the user-provided value. */
@Input()
Expand Down
4 changes: 2 additions & 2 deletions src/lib/grid-list/grid-tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export class MatGridTile {
/** Amount of rows that the grid tile takes up. */
@Input()
get rowspan(): number { return this._rowspan; }
set rowspan(value) { this._rowspan = coerceToNumber(value); }
set rowspan(value: number) { this._rowspan = coerceToNumber(value); }

/** Amount of columns that the grid tile takes up. */
@Input()
get colspan(): number { return this._colspan; }
set colspan(value) { this._colspan = coerceToNumber(value); }
set colspan(value: number) { this._colspan = coerceToNumber(value); }

/**
* Sets the style of the grid-tile element. Needs to be set manually to avoid
Expand Down
4 changes: 2 additions & 2 deletions src/lib/input/autosize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ export class MatTextareaAutosize implements AfterViewInit, DoCheck, OnDestroy {

/** Minimum amount of rows in the textarea. */
@Input('matAutosizeMinRows')
get minRows() { return this._minRows; }
set minRows(value: number) {
this._minRows = value;
this._setMinHeight();
}
get minRows(): number { return this._minRows; }

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