TypeScript error

TS7017: Reading a global through globalThis that nothing declares

  • Error TS7017
  • Reported with noImplicitAny
  • Reported with strict
  • Tested with TypeScript 5.9

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

CodeTS7017
MessageElement implicitly has an 'any' type because type '{0}' has no index signature.
TypeScript's categoryerror
Listed underImplicit 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

debug.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: debug.js(4,18): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. debug.js(4,18): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. debug.js(4,18): error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. checked 21 October 2026
/** @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.
}
Reading a property of globalThis that nothing declares.
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.
  • noImplicitAny is on (part of strict); without it the read is silently any.

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.

debug.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
/** @param {string} message */
export function debug(message) {
  if (globalThis.DEBUG) console.log(message);
}
Declare the global with var in a .d.ts file.
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 name DEBUG work, but globalThis.DEBUG is then TS2339: only var declarations are properties of globalThis.
  • Indexing your own objects with a string key is a different message, TS7053.

Sources

Last reviewed 20 October 2026.