Skip to content

Commit 9cd3132

Browse files
jelbournvivian-hu-zz
authored andcommitted
chore: fix implicit-any error in drag-styling.ts (#13500)
1 parent f3555f1 commit 9cd3132

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9+
10+
// Helper type that ignores `readonly` properties. This is used in
11+
// `extendStyles` to ignore the readonly properties on CSSStyleDeclaration
12+
// since we won't be touching those anyway.
13+
type Writeable<T> = { -readonly [P in keyof T]-?: T[P] };
14+
915
/**
1016
* Extended CSSStyleDeclaration that includes a couple of drag-related
1117
* properties that aren't in the built-in TS typings.
@@ -19,10 +25,12 @@ interface DragCSSStyleDeclaration extends CSSStyleDeclaration {
1925
* Shallow-extends a stylesheet object with another stylesheet object.
2026
* @docs-private
2127
*/
22-
export function extendStyles(dest: CSSStyleDeclaration, source: Partial<DragCSSStyleDeclaration>) {
28+
export function extendStyles(
29+
dest: Writeable<CSSStyleDeclaration>,
30+
source: Partial<DragCSSStyleDeclaration>) {
2331
for (let key in source) {
2432
if (source.hasOwnProperty(key)) {
25-
dest[key!] = source[key];
33+
dest[key as keyof CSSStyleDeclaration] = source[key as keyof CSSStyleDeclaration];
2634
}
2735
}
2836

0 commit comments

Comments
 (0)