Skip to content

Commit

Permalink
refactor(core): support noUncheckedIndexedAccess (#8622)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Aug 22, 2024
1 parent 4fa7631 commit 071eff9
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
automation-id="tui-calendar-sheet__row"
class="t-row"
>
<ng-container *tuiRepeatTimes="let colIndex of sheet[rowIndex].length">
<ng-container *tuiLet="sheet[rowIndex][colIndex] as item">
<ng-container *tuiRepeatTimes="let colIndex of sheet[rowIndex]?.length || 0">
<ng-container *tuiLet="sheet[rowIndex]?.[colIndex] as item">
<div
*ngIf="!itemIsUnavailable(item) || showAdjacent"
*ngIf="item && (!itemIsUnavailable(item) || showAdjacent)"
automation-id="tui-calendar-sheet__cell"
class="t-cell"
[attr.data-range]="getItemRange(item)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ICONS: Record<string, string> = {
/** Default values for the notification options. */
export const TUI_NOTIFICATION_DEFAULT_OPTIONS: TuiNotificationOptions = {
appearance: 'info',
icon: (appearance) => ICONS[appearance],
icon: (appearance) => ICONS[appearance] ?? '',
size: 'l',
};

Expand Down
4 changes: 4 additions & 0 deletions projects/core/components/textfield/textfield.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,8 @@ export class TuiTextfieldComponent<T> implements TuiDataListHost<T> {
protected get hasLabel(): boolean {
return Boolean(this.label?.nativeElement?.childNodes.length);
}

protected onResize(entry: readonly ResizeObserverEntry[]): void {
this.side = entry[0]?.contentRect?.width || 0;
}
}
2 changes: 1 addition & 1 deletion projects/core/components/textfield/textfield.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ng-content select="label" />
<span
class="t-content"
(waResizeObserver)="side = $event[0].contentRect.width"
(waResizeObserver)="onResize($event)"
>
<ng-content />
<button
Expand Down
2 changes: 1 addition & 1 deletion projects/core/pipes/month/month.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export class TuiMonthPipe implements PipeTransform {
private readonly months$ = inject(TUI_MONTHS);

public transform({month}: TuiMonth): Observable<string> {
return this.months$.pipe(map((months) => months[month]));
return this.months$.pipe(map((months) => months[month] || months[0]));
}
}
2 changes: 1 addition & 1 deletion projects/core/services/breakpoint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class TuiBreakpointService extends Observable<TuiBreakpointMediaKey | nul

private readonly stream$ = inject(TUI_WINDOW_SIZE).pipe(
map(({width}) => this.sorted.find((size) => size > width)),
map((key) => this.invert[key || this.sorted[this.sorted.length - 1]]),
map((key) => this.invert[key || this.sorted[this.sorted.length - 1] || 0]),
distinctUntilChanged(),
tuiZoneOptimized(inject(NgZone)),
shareReplay({bufferSize: 1, refCount: true}),
Expand Down
2 changes: 1 addition & 1 deletion projects/core/utils/format/number-to-string-without-exp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function tuiNumberToStringWithoutExp(value: number): string {
let valueWithoutExp = valueAsString;

if (expPart) {
const [, fractionalPart] = numberPart.split('.');
const [, fractionalPart = ''] = numberPart?.split('.') ?? [];
const decimalDigits = Number(expPart) + (fractionalPart?.length || 0);

valueWithoutExp = value.toFixed(decimalDigits);
Expand Down

0 comments on commit 071eff9

Please sign in to comment.