Typescript: error: Property 'innnerHTML' does not exist on type 'Element'

Created on 23 Nov 2015  路  8Comments  路  Source: microsoft/TypeScript

I am getting this error with v1.6.3 with the following code:

document.querySelector('body>section.container').innerHTML  // error: TS2339

To remedy it, I had to explicitly cast it as HTMLElement:

(<HTMLElement>document.querySelector('body>section.container')).innerHTML  // it works!

However, innerHTML is supported by Element interface:
https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML.

lib.d.ts Fixed Suggestion help wanted

All 8 comments

PRs are appreciated. here is how to send lib.d.ts PRs: https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes

I would like to try to fix this bug, is it possible to assigned it to me ?
Thanks !

@lgolven feel free to send a PR for it.

@mhegazy Is this a correct way to fix the problem?

Thanks @MartyIX! This will just need to be synced up with the repo.

Well, Element.outerHTML is still missing :(

@duanyao Be the pull request you want to see in the world :wink:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manekinekko picture manekinekko  路  3Comments

DanielRosenwasser picture DanielRosenwasser  路  3Comments

kyasbal-1994 picture kyasbal-1994  路  3Comments

bgrieder picture bgrieder  路  3Comments

weswigham picture weswigham  路  3Comments