Skip to content

Commit

Permalink
fix: Fix compilation issues with TypeScript 4.4
Browse files Browse the repository at this point in the history
The type `ClientRect` has changed in TS4.4. This casts the assignment to ClientRect type in order to make it build with TS4.4

PiperOrigin-RevId: 395252281
  • Loading branch information
material-web-copybara authored and Copybara-Service committed Sep 7, 2021
1 parent 42d175e commit 7246447
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 26 deletions.
4 changes: 2 additions & 2 deletions packages/mdc-chips/action/component-ripple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export function computePrimaryActionRippleClientRect(
top: clientRect.top,
right: clientRect.right,
bottom: clientRect.bottom,
left: clientRect.left,
};
left: clientRect.left
} as any;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/mdc-chips/action/test/component-ripple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('ripple', () => {
left: 10,
bottom: 42,
right: 110,
};
} as any;

expect(computePrimaryActionRippleClientRect(rect, '')).toEqual(rect);
});
Expand All @@ -47,7 +47,7 @@ describe('ripple', () => {
left: 10,
bottom: 42,
right: 110,
};
} as any;

expect(computePrimaryActionRippleClientRect(rect, 'xyz'))
.toEqual(rect);
Expand All @@ -61,7 +61,7 @@ describe('ripple', () => {
left: 10,
bottom: 42,
right: 110,
};
} as any;

expect(computePrimaryActionRippleClientRect(rect, '20YYpx'))
.toEqual(rect);
Expand All @@ -75,7 +75,7 @@ describe('ripple', () => {
left: 10,
bottom: 42,
right: 110,
};
} as any;

expect(computePrimaryActionRippleClientRect(rect, '20px')).toEqual({
...rect,
Expand Down
4 changes: 2 additions & 2 deletions packages/mdc-chips/deprecated/chip/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const emptyClientRect = {
right: 0,
top: 0,
width: 0,
};
} as any;

enum FocusBehavior {
SHOULD_FOCUS,
Expand Down Expand Up @@ -153,7 +153,7 @@ export class MDCChipFoundation extends MDCFoundation<MDCChipAdapter> {
right: rootRect.right,
top: rootRect.top,
width: rootRect.width + checkmarkRect.height,
};
} as any;
}
}

Expand Down
12 changes: 6 additions & 6 deletions packages/mdc-menu-surface/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,20 +377,20 @@ export class MDCMenuSurfaceFoundation extends
left: this.position.x,
width: 0,
height: 0,
};
} as any;
// tslint:enable:object-literal-sort-keys
}

return {
anchorSize: anchorRect,
anchorSize: anchorRect!,
bodySize,
surfaceSize: this.dimensions,
viewportDistance: {
// tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
top: anchorRect.top,
right: viewportSize.width - anchorRect.right,
bottom: viewportSize.height - anchorRect.bottom,
left: anchorRect.left,
top: anchorRect!.top,
right: viewportSize.width - anchorRect!.right,
bottom: viewportSize.height - anchorRect!.bottom,
left: anchorRect!.left,
// tslint:enable:object-literal-sort-keys
},
viewportSize,
Expand Down
3 changes: 2 additions & 1 deletion packages/mdc-ripple/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export class MDCRippleFoundation extends MDCFoundation<MDCRippleAdapter> {
return {
addClass: () => undefined,
browserSupportsCssVars: () => true,
computeBoundingRect: () => ({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
computeBoundingRect: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
containsEventTarget: () => true,
deregisterDocumentInteractionHandler: () => undefined,
deregisterInteractionHandler: () => undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-segmented-button/segment/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const emptyClientRect = {
right: 0,
top: 0,
width: 0,
};
} as any;

export class MDCSegmentedButtonSegmentFoundation extends
MDCFoundation<MDCSegmentedButtonSegmentAdapter> {
Expand Down
4 changes: 2 additions & 2 deletions packages/mdc-slider/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ export class MDCSliderFoundation extends MDCFoundation<MDCSliderAdapter> {
isInputFocused: () => false,
getThumbKnobWidth: () => 0,
getThumbBoundingClientRect: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
getBoundingClientRect: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
isRTL: () => false,
setThumbStyleProperty: () => undefined,
removeThumbStyleProperty: () => undefined,
Expand Down
6 changes: 4 additions & 2 deletions packages/mdc-tab-bar/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ export class MDCTabBarFoundation extends MDCFoundation<MDCTabBarAdapter> {
activateTabAtIndex: () => undefined,
deactivateTabAtIndex: () => undefined,
focusTabAtIndex: () => undefined,
getTabIndicatorClientRectAtIndex: () => ({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
getTabDimensionsAtIndex: () => ({rootLeft: 0, rootRight: 0, contentLeft: 0, contentRight: 0}),
getTabIndicatorClientRectAtIndex: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
getTabDimensionsAtIndex: () =>
({rootLeft: 0, rootRight: 0, contentLeft: 0, contentRight: 0}),
getPreviousActiveTabIndex: () => -1,
getFocusedTabIndex: () => -1,
getIndexOfTabById: () => -1,
Expand Down
3 changes: 2 additions & 1 deletion packages/mdc-tab-indicator/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export abstract class MDCTabIndicatorFoundation extends MDCFoundation<MDCTabIndi
return {
addClass: () => undefined,
removeClass: () => undefined,
computeContentClientRect: () => ({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
computeContentClientRect: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
setContentStyleProperty: () => undefined,
};
// tslint:enable:object-literal-sort-keys
Expand Down
6 changes: 4 additions & 2 deletions packages/mdc-tab-scroller/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ export class MDCTabScrollerFoundation extends MDCFoundation<MDCTabScrollerAdapte
getScrollAreaScrollLeft: () => 0,
getScrollContentOffsetWidth: () => 0,
getScrollAreaOffsetWidth: () => 0,
computeScrollAreaClientRect: () => ({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
computeScrollContentClientRect: () => ({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
computeScrollAreaClientRect: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
computeScrollContentClientRect: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
computeHorizontalScrollbarHeight: () => 0,
};
// tslint:enable:object-literal-sort-keys
Expand Down
6 changes: 3 additions & 3 deletions packages/mdc-tooltip/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ export class MDCTooltipFoundation extends MDCFoundation<MDCTooltipAdapter> {
getViewportHeight: () => 0,
getTooltipSize: () => ({width: 0, height: 0}),
getAnchorBoundingRect: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
getParentBoundingRect: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
getAnchorAttribute: () => null,
setAnchorAttribute: () => null,
isRTL: () => false,
Expand All @@ -82,7 +82,7 @@ export class MDCTooltipFoundation extends MDCFoundation<MDCTooltipAdapter> {
deregisterWindowEventHandler: () => undefined,
notifyHidden: () => undefined,
getTooltipCaretBoundingRect: () =>
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0}),
({top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0} as any),
setTooltipCaretStyle: () => undefined,
clearTooltipCaretStyles: () => undefined,
getActiveElement: () => null,
Expand Down

0 comments on commit 7246447

Please sign in to comment.