I'm attempting to edit the styles of all the parent elements of an element within my shadowroot using a function call, but I keep getting Property 'style' does not exist on type 'Element'. Here is my code:
var child = this.shadowRoot!.host;
var parents = [];
while(child) {
child = child.parentElement as HTMLElement;
parents.unshift(child);
}
parents.forEach(element => {
element.style.height='100vh';
element.style.width='100vw';
})
I attempted to define the parents array as HTMLElements specifically, but keep getting the error Conversion of type 'never[]' to type 'HTMLElement' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
How can I either define the parents array as an empty array of HTMLElements specifically, or access the 'style' property of my elements otherwise?