Skip to content

Commit

Permalink
refactor: change isDateInstance return type to is D (#18786)
Browse files Browse the repository at this point in the history
* refactor: change isDateInstance return type to is D

* refactor: update core.d.ts
  • Loading branch information
DevTrong committed Mar 21, 2020
1 parent 54bbb90 commit 4ea7157
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/material-moment-adapter/adapter/moment-date-adapter.ts
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
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
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
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 @@ -377,7 +377,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

0 comments on commit 4ea7157

Please sign in to comment.