From 2222a096c8418c9bc02b75a1af7b9fdbe3c8c2f5 Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Mon, 8 Oct 2018 16:33:36 -0700 Subject: [PATCH] chore: fix implicit-any error in drag-styling.ts --- src/cdk/drag-drop/drag-styling.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cdk/drag-drop/drag-styling.ts b/src/cdk/drag-drop/drag-styling.ts index 1965e3342ce0..b466db24aaee 100644 --- a/src/cdk/drag-drop/drag-styling.ts +++ b/src/cdk/drag-drop/drag-styling.ts @@ -6,6 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ + +// Helper type that ignores `readonly` properties. This is used in +// `extendStyles` to ignore the readonly properties on CSSStyleDeclaration +// since we won't be touching those anyway. +type Writeable = { -readonly [P in keyof T]-?: T[P] }; + /** * Extended CSSStyleDeclaration that includes a couple of drag-related * properties that aren't in the built-in TS typings. @@ -19,10 +25,12 @@ interface DragCSSStyleDeclaration extends CSSStyleDeclaration { * Shallow-extends a stylesheet object with another stylesheet object. * @docs-private */ -export function extendStyles(dest: CSSStyleDeclaration, source: Partial) { +export function extendStyles( + dest: Writeable, + source: Partial) { for (let key in source) { if (source.hasOwnProperty(key)) { - dest[key!] = source[key]; + dest[key as keyof CSSStyleDeclaration] = source[key as keyof CSSStyleDeclaration]; } }