May 28, 2023

Type ‘Typeof GlobalThis’ Has No Index Signature

I was having a similar issue and I found that node’s global typings were¬†changed recently-ish; you can now override them by doing:

// global.d.ts
declare global {
    function someFunction(): string;
    var someVariable: string;
}

Note: this will not work with let or const you must use var.

// index.ts
global.someFunction = () => "some value";
global.someVariable = "some value";

Leave a Reply