Skip to content

Commit ac7035b

Browse files
committed
refactor: remove any type from ts4.4 upgrade regarding
Removes the `any` type used in the previous ts4.4 upgrade PR when refering to the style property on the element. Creates a new type to work around the built in `CSSStyleDeclaration` not including `webkitTapHighlightColor`.
1 parent 3913883 commit ac7035b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/cdk/drag-drop/drag-ref.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ import {getMutableClientRect, adjustClientRect} from './client-rect';
3333
import {ParentPositionTracker} from './parent-position-tracker';
3434
import {deepCloneNode} from './clone-node';
3535

36+
// CSSStyleDeclaration does not include webkitTapHighlightcolor. Making a type for this to avoid
37+
// using `any` type.
38+
type _CSSStyleDeclaration = CSSStyleDeclaration & { webkitTapHighlightColor?: string|null};
39+
40+
3641
/** Object that can be used to configure the behavior of DragRef. */
3742
export interface DragRefConfig {
3843
/**
@@ -756,7 +761,8 @@ export class DragRef<T = any> {
756761
this._toggleNativeDragInteractions();
757762

758763
if (this._handles) {
759-
(this._rootElement.style as any).webkitTapHighlightColor = this._rootElementTapHighlight;
764+
(this._rootElement.style as _CSSStyleDeclaration).webkitTapHighlightColor =
765+
this._rootElementTapHighlight;
760766
}
761767

762768
if (!this._hasStartedDragging) {
@@ -884,7 +890,7 @@ export class DragRef<T = any> {
884890
// otherwise iOS will still add it, even though all the drag interactions on the handle
885891
// are disabled.
886892
if (this._handles.length) {
887-
const rootStyles = rootElement.style as any;
893+
const rootStyles = rootElement.style as _CSSStyleDeclaration;
888894
this._rootElementTapHighlight = rootStyles.webkitTapHighlightColor || '';
889895
rootStyles.webkitTapHighlightColor = 'transparent';
890896
}

0 commit comments

Comments
 (0)