Skip to content

refactor: change isDateInstance return type to is D #18786

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 2 commits into from
Mar 21, 2020
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/material-moment-adapter/adapter/moment-date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class MomentDateAdapter extends DateAdapter<Moment> {
return super.deserialize(value);
}

isDateInstance(obj: any): boolean {
isDateInstance(obj: any): obj is _moment.Moment {
return moment.isMoment(obj);
}

Expand Down
2 changes: 1 addition & 1 deletion src/material/core/datetime/date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export abstract class DateAdapter<D> {
* @param obj The object to check
* @returns Whether the object is a date instance.
*/
abstract isDateInstance(obj: any): boolean;
abstract isDateInstance(obj: any): obj is D;

/**
* Checks whether the given date is valid.
Expand Down
2 changes: 1 addition & 1 deletion src/material/core/datetime/native-date-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export class NativeDateAdapter extends DateAdapter<Date> {
return super.deserialize(value);
}

isDateInstance(obj: any) {
isDateInstance(obj: any): obj is Date {
return obj instanceof Date;
}

Expand Down
4 changes: 2 additions & 2 deletions tools/public_api_guard/material/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export declare abstract class DateAdapter<D> {
abstract getYear(date: D): number;
abstract getYearName(date: D): string;
abstract invalid(): D;
abstract isDateInstance(obj: any): boolean;
abstract isDateInstance(obj: any): obj is D;
abstract isValid(date: D): boolean;
abstract parse(value: any, parseFormat: any): D | null;
sameDate(first: D | null, second: D | null): boolean;
Expand Down Expand Up @@ -375,7 +375,7 @@ export declare class NativeDateAdapter extends DateAdapter<Date> {
getYear(date: Date): number;
getYearName(date: Date): string;
invalid(): Date;
isDateInstance(obj: any): boolean;
isDateInstance(obj: any): obj is Date;
isValid(date: Date): boolean;
parse(value: any): Date | null;
toIso8601(date: Date): string;
Expand Down