Closed
Description
I'm using Typescript to write a content script for a Firefox extension. These run in a special environment in which a number of variables are pre-defined, self
being one of them. I can use declare var content;
, etc. to access them in TypeScript easily.
However, they do not run in the window environment (at least not directly), so window
may not be defined, and self
does not refer to window.self. Yet, when I do declare var self;
, I get the following error:
error TS2403: Subsequent variable declarations must have the same type. Variable 'self' must be of type 'Window', but here has type 'any'
So far, I haven't been able to find a way to convince tsc
that self
is actually a different type. This surprised me, because as far as I know, Typescript is not specific to the browser context. Should there be a flag to specify the runtime environment (or absence of one)?