Skip to content

newNativeNonConstructors

Disallows using new with global non-constructor functions like Symbol and BigInt.

✅ This rule is included in the ts untyped preset.

The global Symbol and BigInt functions are not constructors and will throw a TypeError when called with the new keyword. These functions should be called directly without new to create their respective values.

const symbol = new Symbol("description");
const bigNumber = new BigInt(42);
function create() {
return new BigInt(100);
}

This rule is not configurable.

If you have globally overridden BigInt and/or Symbol with classes that are meant to be used as constructors, you may want to disable this rule. However, overriding these names is generally not recommended as it can cause confusion with the global functions.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.