Stencil: Error: Property 'style' does not exist on type 'Element'

Created on 12 Nov 2017  路  5Comments  路  Source: ionic-team/stencil

Stencil version:

 @stencil/[email protected]

I'm submitting a:

Current behavior:
With this code:

children[i].style.display = 'none';

I had this error: Property 'style' does not exist on type 'Element'.

Expected behavior:
The code

children[i].style.display = 'none';

shouldn't be an error.

Steps to reproduce:

Related code:

children[i].style.display = 'none';

Other information:
I fixed with:

children[i]['style'].display = 'none';  no error. 

I think the problem is in a kind of declaration file of typescript.

Most helpful comment

Well... it gives an error if children has type Element[], just cast it to HTMLElement

(children[i] as HTMLElement).style.display = 'none';

I would not consider this a stencil error, since the types for the DOM API are provided by TS itself

All 5 comments

Well... it gives an error if children has type Element[], just cast it to HTMLElement

(children[i] as HTMLElement).style.display = 'none';

I would not consider this a stencil error, since the types for the DOM API are provided by TS itself

Ok thank you very much

@henrykode what is the solution of this error? i have also same problem

@sureshokp try the solution of manucorporat, it works for me.

Stencil version:

 @stencil/[email protected]

I'm submitting a:

Current behavior:
With this code:

children[i].style.display = 'none';

I had this error: Property 'style' does not exist on type 'Element'.

Expected behavior:
The code

children[i].style.display = 'none';

shouldn't be an error.

Steps to reproduce:

Related code:

children[i].style.display = 'none';

Other information:
I fixed with:

children[i]['style'].display = 'none';  no error. 

I think the problem is in a kind of declaration file of typescript.

Yep. This worked for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MrMcGibblets picture MrMcGibblets  路  3Comments

bekliev picture bekliev  路  3Comments

glemiere picture glemiere  路  3Comments

kensodemann picture kensodemann  路  3Comments

anthonylebrun picture anthonylebrun  路  3Comments