error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. is reported when code reads a property from a type that has no such property and no index signature to fall back on. In JavaScript projects the type is nearly always typeof globalThis: code reads globalThis.DEBUG or globalThis.APP_CONFIG, set by a <script> tag or a test setup file the checker never sees.
On window the same mistake is TS2339 instead. Both mean the same thing: the global exists at run time, but no declaration tells the checker about it.
At a glance
| Code | TS7017 |
|---|---|
| Message | Element implicitly has an 'any' type because type '{0}' has no index signature. |
| TypeScript's category | error |
| Listed under | Implicit any |
| Turned on by | noImplicitAny, strict |
| In .js files | Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file |
The message is TypeScript's own text from its diagnostic messages file (Apache-2.0); {0} is filled in by tsc for each error.
What it looks like
/** @param {string} message */
export function debug(message) {
if (globalThis.DEBUG) console.log(message);error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature.
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} What causes it
- A global set outside the checked files (inline script, server-rendered config, test setup) is read through
globalThis. noImplicitAnyis on (part ofstrict); without it the read is silentlyany.
How to fix it
Declare it with var in a .d.ts file
In a declaration file the config includes, write declare var DEBUG: boolean | undefined;. It must be var: var declarations become properties of globalThis, let and const do not. Include undefined in the type if pages may leave it out.
/** @param {string} message */
export function debug(message) {
if (globalThis.DEBUG) console.log(message);
}jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js", "*.d.ts"]
} Or set it in a checked file
If one of your own .js files sets the global (globalThis.DEBUG = false;), that assignment declares it for every other file in the program, and reads elsewhere pass.
Gotchas
declare const DEBUG: boolean;makes the bare nameDEBUGwork, butglobalThis.DEBUGis then TS2339: onlyvardeclarations are properties ofglobalThis.- Indexing your own objects with a string key is a different message, TS7053.
Sources
- globalThis · MDN Web Docs
- Declaration Reference: Global Variables · TypeScript handbook
- diagnosticMessages.json (TypeScript 5.9.3) · TypeScript on GitHub
Last reviewed 20 October 2026.