Skip to content

Commit

Permalink
fixing typing issue caused by microsoft/TypeScript#35865
Browse files Browse the repository at this point in the history
  • Loading branch information
dvoegelin committed Mar 24, 2022
1 parent f0eaf5b commit d3585c1
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'dayofmonth' })
export class DayOfMonthPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private locale: string = 'en-US') {}
transform(date: Date, locale: string = this.locale, method: string = 'numeric'): string {
transform(date: Date, locale: string = this.locale, method: 'numeric' | '2-digit' = 'numeric'): string {
return new Intl.DateTimeFormat(locale, { day: method }).format(date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
export class EndOfWeekDisplayPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private locale: string = 'en-US') {}

transform(endOfWeek: Date, startOfWeek: Date, locale: string = this.locale, method: string = 'short'): String {
transform(endOfWeek: Date, startOfWeek: Date, locale: string = this.locale, method: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' = 'short'): String {
if (endOfWeek.getMonth() === startOfWeek.getMonth()) {
return new Intl.DateTimeFormat(locale, { day: 'numeric' }).format(endOfWeek);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'hours' })
export class HoursPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private locale: string = 'en-US') {}
transform(date: Date, locale: string = this.locale, method: string = 'numeric'): string {
transform(date: Date, locale: string = this.locale, method: 'numeric' | '2-digit' = 'numeric'): string {
return new Intl.DateTimeFormat(locale, { hour: method }).format(date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'month' })
export class MonthPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private locale: string = 'en-US') {}
transform(date: Date, locale: string = this.locale, method: string = 'long'): string {
transform(date: Date, locale: string = this.locale, method: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' = 'long'): string {
return new Intl.DateTimeFormat(locale, { month: method }).format(date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'monthday' })
export class MonthDayPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private locale: string = 'en-US') {}
transform(date: Date, locale: string = this.locale, method: string = 'short'): string {
transform(date: Date, locale: string = this.locale, method: 'numeric' | '2-digit' | 'long' | 'short' | 'narrow' = 'short'): string {
return new Intl.DateTimeFormat(locale, { month: method, day: 'numeric' }).format(date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'weekday' })
export class WeekdayPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private locale: string = 'en-US') {}
transform(date: Date, locale: string = this.locale, method: string = 'short'): string {
transform(date: Date, locale: string = this.locale, method: 'long' | 'short' | 'narrow' = 'short'): string {
return new Intl.DateTimeFormat(locale, { weekday: method }).format(date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'year' })
export class YearPipe implements PipeTransform {
constructor(@Inject(LOCALE_ID) private locale: string = 'en-US') {}
transform(date: Date, locale: string = this.locale, method: string = 'numeric'): string {
transform(date: Date, locale: string = this.locale, method: 'numeric' | '2-digit' = 'numeric'): string {
return new Intl.DateTimeFormat(locale, { year: method }).format(date);
}
}

0 comments on commit d3585c1

Please sign in to comment.