Skip to content

globalObjectCalls

Reports calling global objects like Math, JSON, or Reflect as functions.

✅ This rule is included in the ts untyped presets.

The global objects Math, JSON, Reflect, and Atomics are not constructors or functions. They are built-in objects that provide utility methods and properties as namespaces. Attempting to call them as functions or instantiate them with new will result in a TypeError at runtime.

const
const result: any
result
= Math();
Error ts(2349) ― This expression is not callable. Type 'Math' has no call signatures.
const
const data: any
data
= JSON();
Error ts(2349) ― This expression is not callable. Type 'JSON' has no call signatures.
const
const reflected: any
reflected
= Reflect();
Error ts(2349) ― This expression is not callable. Type 'typeof Reflect' has no call signatures.
const
const instance: any
instance
= new Atomics();
Error ts(2351) ― This expression is not constructable. Type 'Atomics' has no construct signatures.

This rule is not configurable.

If your codebase redefines these objects and is guaranteed to run in an environment that allows that, you might not want to enable this rule. For example, if you target a legacy runtime with legacy non-standard JavaScript semantics, modern standard practices may not apply to you.

Made with ❤️‍🔥 around the world by the Flint team and contributors.