acvetkov / sinon-chrome

Testing chrome extensions with Node.js
ISC License
437 stars 48 forks source link

how to handle the global variable in typescript? #51

Closed Alino closed 7 years ago

Alino commented 7 years ago

if I use

global.chrome = chrome

typescript gives me error error TS2304: Cannot find name 'global'.

but if I declare global like this

let global = {};
global.chrome = chrome

My tests will fail, because chrome is not defined on the separate file that I am writing tests for.

Alino commented 7 years ago

ok I was able to work around this by doing this

declare var global: any;
global.chrome = chrome
acvetkov commented 7 years ago

Hi, @Alino .

global is Node.js global object. You should use window object, if you run your tests under browser.