Types for global variables
I have defined a global variable:
globalThis.Args = validateArguments(Deno.args);
Now whenever I use it I get TS error: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.deno-ts(7017)
How can I fix this?1 Reply
Hi.
Try to create a new d.ts file like
global.d.ts
with the contents
Add a reference to this d.ts
file in the compiler options in deno.json
You should be able to access Args
from globalThis
this should also pass the deno check command to typecheck your code