-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
TypeScript Version: 2.1.1
Code
/**
* typescript says `[ts] Property 'x' does not exist on type 'Window'.`
* for all of these, but they all exist and work in browsers:
*/
window.Document
window.eval // <- this one is useful for "indirect eval" - i ran into this bug once earlier
window.EventTarget
window.Function
window.MouseEvent
window.HTMLElement
window.DocumentFragment
/**
* same thing here, this is more similar to what i was doing when i found this bug
*/
var iframe = document.createElement("iframe");
iframe.contentWindow.Document
// etc etc
// somewhat important note: there are probably more, i just quickly came up with these
/**
* they work in typescript if accessed this way:
*/
Document
eval
EventTarget
Function
MouseEvent
HTMLElement
DocumentFragment(you can paste it in the typescript playground here: https://www.typescriptlang.org/play/)
Expected behavior:
there should be no errors, all the properties should exist on window
Actual behavior:
the properties don't exist on window but seem to exist in a "global scope" somehow so they're only visible to typescript when accessed directly
normally i guess i could just not use the window. prefix for accessing these properties, but that's not an option for indirect eval via window.eval or accessing the properties from other windows (iframes, window.opener, window.top, etc)
mfulton26
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created