diff --git a/packages/core-js-builder/index.js b/packages/core-js-builder/index.js index 77e89edf4a76..e5f8dcb053e2 100644 --- a/packages/core-js-builder/index.js +++ b/packages/core-js-builder/index.js @@ -33,7 +33,7 @@ module.exports = async function ({ filename = null, summary = {}, } = {}) { - if (!['bundle', 'cjs', 'esm'].includes(format)) throw TypeError('Incorrect output type'); + if (!['bundle', 'cjs', 'esm'].includes(format)) throw new TypeError('Incorrect output type'); summary = { comment: normalizeSummary(summary.comment), console: normalizeSummary(summary.console) }; const TITLE = filename !== null || filename !== undefined ? filename : '`core-js`'; diff --git a/packages/core-js-compat/compat.js b/packages/core-js-compat/compat.js index 8a60da992313..b179e7fdff64 100644 --- a/packages/core-js-compat/compat.js +++ b/packages/core-js-compat/compat.js @@ -7,7 +7,7 @@ const allModules = require('./modules'); const targetsParser = require('./targets-parser'); function throwInvalidFilter(filter) { - throw TypeError(`Specified invalid module name or pattern: ${ filter }`); + throw new TypeError(`Specified invalid module name or pattern: ${ filter }`); } function atLeastSomeModules(modules, filter) { diff --git a/packages/core-js-compat/get-modules-list-for-target-version.js b/packages/core-js-compat/get-modules-list-for-target-version.js index 104c9db01aa3..e091c64a7fc8 100644 --- a/packages/core-js-compat/get-modules-list-for-target-version.js +++ b/packages/core-js-compat/get-modules-list-for-target-version.js @@ -6,7 +6,7 @@ const modules = require('./modules'); module.exports = function (raw) { const corejs = semver(raw); if (corejs.major !== 3) { - throw RangeError('This version of `core-js-compat` works only with `core-js@3`.'); + throw new RangeError('This version of `core-js-compat` works only with `core-js@3`.'); } const result = []; for (const version of Object.keys(modulesByVersions)) { diff --git a/packages/core-js-compat/helpers.js b/packages/core-js-compat/helpers.js index 52e9b948cdb4..f9abfc45d63b 100644 --- a/packages/core-js-compat/helpers.js +++ b/packages/core-js-compat/helpers.js @@ -7,7 +7,7 @@ function semver(input) { // eslint-disable-next-line new-cap -- ok if (!(this instanceof semver)) return new semver(input); const match = /(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(input); - if (!match) throw TypeError(`Invalid version: ${ input }`); + if (!match) throw new TypeError(`Invalid version: ${ input }`); const [, $major, $minor, $patch] = match; this.major = +$major; this.minor = $minor ? +$minor : 0; diff --git a/packages/core-js-pure/override/internals/a-map.js b/packages/core-js-pure/override/internals/a-map.js index 6126422ad72f..0ebf731786be 100644 --- a/packages/core-js-pure/override/internals/a-map.js +++ b/packages/core-js-pure/override/internals/a-map.js @@ -1,8 +1,10 @@ 'use strict'; var tryToString = require('../internals/try-to-string'); +var $TypeError = TypeError; + // Perform ? RequireInternalSlot(M, [[MapData]]) module.exports = function (it) { if (typeof it == 'object' && 'size' in it && 'has' in it && 'get' in it && 'set' in it && 'delete' in it && 'entries' in it) return it; - throw TypeError(tryToString(it) + ' is not a map'); + throw new $TypeError(tryToString(it) + ' is not a map'); }; diff --git a/packages/core-js-pure/override/internals/a-set.js b/packages/core-js-pure/override/internals/a-set.js index b65f49313873..555e2093d429 100644 --- a/packages/core-js-pure/override/internals/a-set.js +++ b/packages/core-js-pure/override/internals/a-set.js @@ -1,8 +1,10 @@ 'use strict'; var tryToString = require('../internals/try-to-string'); +var $TypeError = TypeError; + // Perform ? RequireInternalSlot(M, [[SetData]]) module.exports = function (it) { if (typeof it == 'object' && 'size' in it && 'has' in it && 'add' in it && 'delete' in it && 'keys' in it) return it; - throw TypeError(tryToString(it) + ' is not a set'); + throw new $TypeError(tryToString(it) + ' is not a set'); }; diff --git a/packages/core-js-pure/override/internals/a-weak-map.js b/packages/core-js-pure/override/internals/a-weak-map.js index 700145c11f28..a7fe18073668 100644 --- a/packages/core-js-pure/override/internals/a-weak-map.js +++ b/packages/core-js-pure/override/internals/a-weak-map.js @@ -1,8 +1,10 @@ 'use strict'; var tryToString = require('../internals/try-to-string'); +var $TypeError = TypeError; + // Perform ? RequireInternalSlot(M, [[WeakMapData]]) module.exports = function (it) { if (typeof it == 'object' && 'has' in it && 'get' in it && 'set' in it && 'delete') return it; - throw TypeError(tryToString(it) + ' is not a weakmap'); + throw new $TypeError(tryToString(it) + ' is not a weakmap'); }; diff --git a/packages/core-js-pure/override/internals/a-weak-set.js b/packages/core-js-pure/override/internals/a-weak-set.js index 8fa373cb5f32..1915075cdfc0 100644 --- a/packages/core-js-pure/override/internals/a-weak-set.js +++ b/packages/core-js-pure/override/internals/a-weak-set.js @@ -1,8 +1,10 @@ 'use strict'; var tryToString = require('../internals/try-to-string'); +var $TypeError = TypeError; + // Perform ? RequireInternalSlot(M, [[WeakSetData]]) module.exports = function (it) { if (typeof it == 'object' && 'has' in it && 'add' in it && 'delete' in it) return it; - throw TypeError(tryToString(it) + ' is not a weakset'); + throw new $TypeError(tryToString(it) + ' is not a weakset'); }; diff --git a/packages/core-js/internals/a-callable.js b/packages/core-js/internals/a-callable.js index 164facc1b1e3..0aae1ad54f05 100644 --- a/packages/core-js/internals/a-callable.js +++ b/packages/core-js/internals/a-callable.js @@ -7,5 +7,5 @@ var $TypeError = TypeError; // `Assert: IsCallable(argument) is true` module.exports = function (argument) { if (isCallable(argument)) return argument; - throw $TypeError(tryToString(argument) + ' is not a function'); + throw new $TypeError(tryToString(argument) + ' is not a function'); }; diff --git a/packages/core-js/internals/a-constructor.js b/packages/core-js/internals/a-constructor.js index 301687becb1e..efede0f96de4 100644 --- a/packages/core-js/internals/a-constructor.js +++ b/packages/core-js/internals/a-constructor.js @@ -7,5 +7,5 @@ var $TypeError = TypeError; // `Assert: IsConstructor(argument) is true` module.exports = function (argument) { if (isConstructor(argument)) return argument; - throw $TypeError(tryToString(argument) + ' is not a constructor'); + throw new $TypeError(tryToString(argument) + ' is not a constructor'); }; diff --git a/packages/core-js/internals/a-possible-prototype.js b/packages/core-js/internals/a-possible-prototype.js index 5ef84a5db8b8..e9e6af363614 100644 --- a/packages/core-js/internals/a-possible-prototype.js +++ b/packages/core-js/internals/a-possible-prototype.js @@ -6,5 +6,5 @@ var $TypeError = TypeError; module.exports = function (argument) { if (typeof argument == 'object' || isCallable(argument)) return argument; - throw $TypeError("Can't set " + $String(argument) + ' as a prototype'); + throw new $TypeError("Can't set " + $String(argument) + ' as a prototype'); }; diff --git a/packages/core-js/internals/an-instance.js b/packages/core-js/internals/an-instance.js index ecd09e0bd1dc..ba3422d9ff37 100644 --- a/packages/core-js/internals/an-instance.js +++ b/packages/core-js/internals/an-instance.js @@ -5,5 +5,5 @@ var $TypeError = TypeError; module.exports = function (it, Prototype) { if (isPrototypeOf(Prototype, it)) return it; - throw $TypeError('Incorrect invocation'); + throw new $TypeError('Incorrect invocation'); }; diff --git a/packages/core-js/internals/an-object.js b/packages/core-js/internals/an-object.js index 76b4f5ea01d3..c782e781dfc9 100644 --- a/packages/core-js/internals/an-object.js +++ b/packages/core-js/internals/an-object.js @@ -7,5 +7,5 @@ var $TypeError = TypeError; // `Assert: Type(argument) is Object` module.exports = function (argument) { if (isObject(argument)) return argument; - throw $TypeError($String(argument) + ' is not an object'); + throw new $TypeError($String(argument) + ' is not an object'); }; diff --git a/packages/core-js/internals/array-buffer-byte-length.js b/packages/core-js/internals/array-buffer-byte-length.js index ae75aadea01c..c20be7455215 100644 --- a/packages/core-js/internals/array-buffer-byte-length.js +++ b/packages/core-js/internals/array-buffer-byte-length.js @@ -8,6 +8,6 @@ var $TypeError = TypeError; // - Perform ? RequireInternalSlot(O, [[ArrayBufferData]]). // - If IsSharedArrayBuffer(O) is true, throw a TypeError exception. module.exports = uncurryThisAccessor(ArrayBuffer.prototype, 'byteLength', 'get') || function (O) { - if (classof(O) !== 'ArrayBuffer') throw $TypeError('ArrayBuffer expected'); + if (classof(O) !== 'ArrayBuffer') throw new $TypeError('ArrayBuffer expected'); return O.byteLength; }; diff --git a/packages/core-js/internals/array-buffer-transfer.js b/packages/core-js/internals/array-buffer-transfer.js index f9005149f407..44bc4b3b45b4 100644 --- a/packages/core-js/internals/array-buffer-transfer.js +++ b/packages/core-js/internals/array-buffer-transfer.js @@ -24,7 +24,7 @@ module.exports = PROPER_TRANSFER && function (arrayBuffer, newLength, preserveRe var byteLength = arrayBufferByteLength(arrayBuffer); var newByteLength = newLength === undefined ? byteLength : toIndex(newLength); var fixedLength = !isResizable || !isResizable(arrayBuffer); - if (isDetached(arrayBuffer)) throw TypeError('ArrayBuffer is detached'); + if (isDetached(arrayBuffer)) throw new TypeError('ArrayBuffer is detached'); var newBuffer = structuredClone(arrayBuffer, { transfer: [arrayBuffer] }); if (byteLength === newByteLength && (preserveResizability || fixedLength)) return newBuffer; if (byteLength >= newByteLength && (!preserveResizability || fixedLength)) return slice(newBuffer, 0, newByteLength); diff --git a/packages/core-js/internals/array-buffer-view-core.js b/packages/core-js/internals/array-buffer-view-core.js index ada9c040bb76..4cf1d0db9d46 100644 --- a/packages/core-js/internals/array-buffer-view-core.js +++ b/packages/core-js/internals/array-buffer-view-core.js @@ -77,12 +77,12 @@ var isTypedArray = function (it) { var aTypedArray = function (it) { if (isTypedArray(it)) return it; - throw TypeError('Target is not a typed array'); + throw new TypeError('Target is not a typed array'); }; var aTypedArrayConstructor = function (C) { if (isCallable(C) && (!setPrototypeOf || isPrototypeOf(TypedArray, C))) return C; - throw TypeError(tryToString(C) + ' is not a typed array constructor'); + throw new TypeError(tryToString(C) + ' is not a typed array constructor'); }; var exportTypedArrayMethod = function (KEY, property, forced, options) { @@ -146,7 +146,7 @@ for (NAME in BigIntArrayConstructorsList) { if (!NATIVE_ARRAY_BUFFER_VIEWS || !isCallable(TypedArray) || TypedArray === Function.prototype) { // eslint-disable-next-line no-shadow -- safe TypedArray = function TypedArray() { - throw TypeError('Incorrect invocation'); + throw new TypeError('Incorrect invocation'); }; if (NATIVE_ARRAY_BUFFER_VIEWS) for (NAME in TypedArrayConstructorsList) { if (global[NAME]) setPrototypeOf(global[NAME], TypedArray); diff --git a/packages/core-js/internals/array-buffer.js b/packages/core-js/internals/array-buffer.js index 4671de6061ed..0671919c9acb 100644 --- a/packages/core-js/internals/array-buffer.js +++ b/packages/core-js/internals/array-buffer.js @@ -82,7 +82,7 @@ var get = function (view, count, index, isLittleEndian) { var store = getInternalDataViewState(view); var intIndex = toIndex(index); var boolIsLittleEndian = !!isLittleEndian; - if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX); + if (intIndex + count > store.byteLength) throw new RangeError(WRONG_INDEX); var bytes = store.bytes; var start = intIndex + store.byteOffset; var pack = arraySlice(bytes, start, start + count); @@ -94,7 +94,7 @@ var set = function (view, count, index, conversion, value, isLittleEndian) { var intIndex = toIndex(index); var pack = conversion(+value); var boolIsLittleEndian = !!isLittleEndian; - if (intIndex + count > store.byteLength) throw RangeError(WRONG_INDEX); + if (intIndex + count > store.byteLength) throw new RangeError(WRONG_INDEX); var bytes = store.bytes; var start = intIndex + store.byteOffset; for (var i = 0; i < count; i++) bytes[start + i] = pack[boolIsLittleEndian ? i : count - i - 1]; @@ -123,9 +123,9 @@ if (!NATIVE_ARRAY_BUFFER) { var bufferState = getInternalArrayBufferState(buffer); var bufferLength = bufferState.byteLength; var offset = toIntegerOrInfinity(byteOffset); - if (offset < 0 || offset > bufferLength) throw RangeError('Wrong offset'); + if (offset < 0 || offset > bufferLength) throw new RangeError('Wrong offset'); byteLength = byteLength === undefined ? bufferLength - offset : toLength(byteLength); - if (offset + byteLength > bufferLength) throw RangeError(WRONG_LENGTH); + if (offset + byteLength > bufferLength) throw new RangeError(WRONG_LENGTH); setInternalState(this, { type: DATA_VIEW, buffer: buffer, diff --git a/packages/core-js/internals/array-reduce.js b/packages/core-js/internals/array-reduce.js index b68d04ce18b2..cefcf3413426 100644 --- a/packages/core-js/internals/array-reduce.js +++ b/packages/core-js/internals/array-reduce.js @@ -23,7 +23,7 @@ var createMethod = function (IS_RIGHT) { } index += i; if (IS_RIGHT ? index < 0 : length <= index) { - throw $TypeError('Reduce of empty array with no initial value'); + throw new $TypeError('Reduce of empty array with no initial value'); } } for (;IS_RIGHT ? index >= 0 : length > index; index += i) if (index in self) { diff --git a/packages/core-js/internals/array-set-length.js b/packages/core-js/internals/array-set-length.js index 08523174e5da..532428026143 100644 --- a/packages/core-js/internals/array-set-length.js +++ b/packages/core-js/internals/array-set-length.js @@ -20,7 +20,7 @@ var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () { module.exports = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) { if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) { - throw $TypeError('Cannot set read only .length'); + throw new $TypeError('Cannot set read only .length'); } return O.length = length; } : function (O, length) { return O.length = length; diff --git a/packages/core-js/internals/array-with.js b/packages/core-js/internals/array-with.js index 5b33bfcea8e8..e4a825e162de 100644 --- a/packages/core-js/internals/array-with.js +++ b/packages/core-js/internals/array-with.js @@ -10,7 +10,7 @@ module.exports = function (O, C, index, value) { var len = lengthOfArrayLike(O); var relativeIndex = toIntegerOrInfinity(index); var actualIndex = relativeIndex < 0 ? len + relativeIndex : relativeIndex; - if (actualIndex >= len || actualIndex < 0) throw $RangeError('Incorrect index'); + if (actualIndex >= len || actualIndex < 0) throw new $RangeError('Incorrect index'); var A = new C(len); var k = 0; for (; k < len; k++) A[k] = k === actualIndex ? value : O[k]; diff --git a/packages/core-js/internals/composite-key.js b/packages/core-js/internals/composite-key.js index 1276d78163ea..6c44f2041c91 100644 --- a/packages/core-js/internals/composite-key.js +++ b/packages/core-js/internals/composite-key.js @@ -43,7 +43,7 @@ module.exports = function () { for (i = 0; i < length; i++) { if (isObject(it = arguments[i])) active = active.next(i, it, true); } - if (this === $Object && active === root) throw $TypeError('Composite keys must contain a non-primitive component'); + if (this === $Object && active === root) throw new $TypeError('Composite keys must contain a non-primitive component'); for (i = 0; i < length; i++) { if (!isObject(it = arguments[i])) active = active.next(i, it, false); } return active; diff --git a/packages/core-js/internals/date-to-iso-string.js b/packages/core-js/internals/date-to-iso-string.js index 199847ab7a61..4fc47a143d1a 100644 --- a/packages/core-js/internals/date-to-iso-string.js +++ b/packages/core-js/internals/date-to-iso-string.js @@ -25,7 +25,7 @@ module.exports = (fails(function () { }) || !fails(function () { nativeDateToISOString.call(new Date(NaN)); })) ? function toISOString() { - if (!$isFinite(thisTimeValue(this))) throw $RangeError('Invalid time value'); + if (!$isFinite(thisTimeValue(this))) throw new $RangeError('Invalid time value'); var date = this; var year = getUTCFullYear(date); var milliseconds = getUTCMilliseconds(date); diff --git a/packages/core-js/internals/date-to-primitive.js b/packages/core-js/internals/date-to-primitive.js index 121bdb7e6111..b72e5dfe2acb 100644 --- a/packages/core-js/internals/date-to-primitive.js +++ b/packages/core-js/internals/date-to-primitive.js @@ -9,6 +9,6 @@ var $TypeError = TypeError; module.exports = function (hint) { anObject(this); if (hint === 'string' || hint === 'default') hint = 'string'; - else if (hint !== 'number') throw $TypeError('Incorrect hint'); + else if (hint !== 'number') throw new $TypeError('Incorrect hint'); return ordinaryToPrimitive(this, hint); }; diff --git a/packages/core-js/internals/delete-property-or-throw.js b/packages/core-js/internals/delete-property-or-throw.js index 6fb636001de1..7265f6f6c013 100644 --- a/packages/core-js/internals/delete-property-or-throw.js +++ b/packages/core-js/internals/delete-property-or-throw.js @@ -4,5 +4,5 @@ var tryToString = require('../internals/try-to-string'); var $TypeError = TypeError; module.exports = function (O, P) { - if (!delete O[P]) throw $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O)); + if (!delete O[P]) throw new $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O)); }; diff --git a/packages/core-js/internals/error-stack-clear.js b/packages/core-js/internals/error-stack-clear.js index e5041295c74f..43b8cd22bb38 100644 --- a/packages/core-js/internals/error-stack-clear.js +++ b/packages/core-js/internals/error-stack-clear.js @@ -4,7 +4,7 @@ var uncurryThis = require('../internals/function-uncurry-this'); var $Error = Error; var replace = uncurryThis(''.replace); -var TEST = (function (arg) { return String($Error(arg).stack); })('zxcasd'); +var TEST = (function (arg) { return String(new $Error(arg).stack); })('zxcasd'); // eslint-disable-next-line redos/no-vulnerable -- safe var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); diff --git a/packages/core-js/internals/error-stack-installable.js b/packages/core-js/internals/error-stack-installable.js index cc500b5d27a6..96b987fb7af2 100644 --- a/packages/core-js/internals/error-stack-installable.js +++ b/packages/core-js/internals/error-stack-installable.js @@ -3,7 +3,7 @@ var fails = require('../internals/fails'); var createPropertyDescriptor = require('../internals/create-property-descriptor'); module.exports = !fails(function () { - var error = Error('a'); + var error = new Error('a'); if (!('stack' in error)) return true; // eslint-disable-next-line es/no-object-defineproperty -- safe Object.defineProperty(error, 'stack', createPropertyDescriptor(1, 7)); diff --git a/packages/core-js/internals/get-iterator.js b/packages/core-js/internals/get-iterator.js index 836ca215e87a..2b4c53e48a90 100644 --- a/packages/core-js/internals/get-iterator.js +++ b/packages/core-js/internals/get-iterator.js @@ -10,5 +10,5 @@ var $TypeError = TypeError; module.exports = function (argument, usingIterator) { var iteratorMethod = arguments.length < 2 ? getIteratorMethod(argument) : usingIterator; if (aCallable(iteratorMethod)) return anObject(call(iteratorMethod, argument)); - throw $TypeError(tryToString(argument) + ' is not iterable'); + throw new $TypeError(tryToString(argument) + ' is not iterable'); }; diff --git a/packages/core-js/internals/get-set-record.js b/packages/core-js/internals/get-set-record.js index 18b29adf04e0..94d225bc55c2 100644 --- a/packages/core-js/internals/get-set-record.js +++ b/packages/core-js/internals/get-set-record.js @@ -33,9 +33,9 @@ module.exports = function (obj) { var numSize = +obj.size; // NOTE: If size is undefined, then numSize will be NaN // eslint-disable-next-line no-self-compare -- NaN check - if (numSize !== numSize) throw $TypeError(INVALID_SIZE); + if (numSize !== numSize) throw new $TypeError(INVALID_SIZE); var intSize = toIntegerOrInfinity(numSize); - if (intSize < 0) throw $RangeError(INVALID_SIZE); + if (intSize < 0) throw new $RangeError(INVALID_SIZE); return new SetRecord( obj, max(intSize, 0), diff --git a/packages/core-js/internals/internal-state.js b/packages/core-js/internals/internal-state.js index 962c49a35f8a..15f3c4428e74 100644 --- a/packages/core-js/internals/internal-state.js +++ b/packages/core-js/internals/internal-state.js @@ -21,7 +21,7 @@ var getterFor = function (TYPE) { return function (it) { var state; if (!isObject(it) || (state = get(it)).type !== TYPE) { - throw TypeError('Incompatible receiver, ' + TYPE + ' required'); + throw new TypeError('Incompatible receiver, ' + TYPE + ' required'); } return state; }; }; @@ -34,7 +34,7 @@ if (NATIVE_WEAK_MAP || shared.state) { store.set = store.set; /* eslint-enable no-self-assign -- prototype methods protection */ set = function (it, metadata) { - if (store.has(it)) throw TypeError(OBJECT_ALREADY_INITIALIZED); + if (store.has(it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); metadata.facade = it; store.set(it, metadata); return metadata; @@ -49,7 +49,7 @@ if (NATIVE_WEAK_MAP || shared.state) { var STATE = sharedKey('state'); hiddenKeys[STATE] = true; set = function (it, metadata) { - if (hasOwn(it, STATE)) throw TypeError(OBJECT_ALREADY_INITIALIZED); + if (hasOwn(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED); metadata.facade = it; createNonEnumerableProperty(it, STATE, metadata); return metadata; diff --git a/packages/core-js/internals/iterate.js b/packages/core-js/internals/iterate.js index 450d63f09457..bcfa5cf0dab6 100644 --- a/packages/core-js/internals/iterate.js +++ b/packages/core-js/internals/iterate.js @@ -46,7 +46,7 @@ module.exports = function (iterable, unboundFunction, options) { iterator = iterable; } else { iterFn = getIteratorMethod(iterable); - if (!iterFn) throw $TypeError(tryToString(iterable) + ' is not iterable'); + if (!iterFn) throw new $TypeError(tryToString(iterable) + ' is not iterable'); // optimisation for array iterators if (isArrayIteratorMethod(iterFn)) { for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) { diff --git a/packages/core-js/internals/map-upsert.js b/packages/core-js/internals/map-upsert.js index c4bf21e7a7ab..28f17f3f62d0 100644 --- a/packages/core-js/internals/map-upsert.js +++ b/packages/core-js/internals/map-upsert.js @@ -16,7 +16,7 @@ module.exports = function upsert(key, updateFn /* , insertFn */) { var insertFn = arguments.length > 2 ? arguments[2] : undefined; var value; if (!isCallable(updateFn) && !isCallable(insertFn)) { - throw $TypeError('At least one callback required'); + throw new $TypeError('At least one callback required'); } if (call(has, map, key)) { value = call(get, map, key); diff --git a/packages/core-js/internals/new-promise-capability.js b/packages/core-js/internals/new-promise-capability.js index a62509872831..dac6549b7c8b 100644 --- a/packages/core-js/internals/new-promise-capability.js +++ b/packages/core-js/internals/new-promise-capability.js @@ -6,7 +6,7 @@ var $TypeError = TypeError; var PromiseCapability = function (C) { var resolve, reject; this.promise = new C(function ($$resolve, $$reject) { - if (resolve !== undefined || reject !== undefined) throw $TypeError('Bad Promise constructor'); + if (resolve !== undefined || reject !== undefined) throw new $TypeError('Bad Promise constructor'); resolve = $$resolve; reject = $$reject; }); diff --git a/packages/core-js/internals/not-a-nan.js b/packages/core-js/internals/not-a-nan.js index b8ff44cdd9c0..61ce8f131831 100644 --- a/packages/core-js/internals/not-a-nan.js +++ b/packages/core-js/internals/not-a-nan.js @@ -4,5 +4,5 @@ var $RangeError = RangeError; module.exports = function (it) { // eslint-disable-next-line no-self-compare -- NaN check if (it === it) return it; - throw $RangeError('NaN is not allowed'); + throw new $RangeError('NaN is not allowed'); }; diff --git a/packages/core-js/internals/not-a-regexp.js b/packages/core-js/internals/not-a-regexp.js index e5c04ab9ebb9..49c81fbc56da 100644 --- a/packages/core-js/internals/not-a-regexp.js +++ b/packages/core-js/internals/not-a-regexp.js @@ -5,6 +5,6 @@ var $TypeError = TypeError; module.exports = function (it) { if (isRegExp(it)) { - throw $TypeError("The method doesn't accept regular expressions"); + throw new $TypeError("The method doesn't accept regular expressions"); } return it; }; diff --git a/packages/core-js/internals/numeric-range-iterator.js b/packages/core-js/internals/numeric-range-iterator.js index 4aae410ea87b..17830a240cb5 100644 --- a/packages/core-js/internals/numeric-range-iterator.js +++ b/packages/core-js/internals/numeric-range-iterator.js @@ -19,10 +19,10 @@ var $TypeError = TypeError; var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(start, end, option, type, zero, one) { // TODO: Drop the first `typeof` check after removing legacy methods in `core-js@4` if (typeof start != type || (end !== Infinity && end !== -Infinity && typeof end != type)) { - throw $TypeError(INCORRECT_RANGE); + throw new $TypeError(INCORRECT_RANGE); } if (start === Infinity || start === -Infinity) { - throw $RangeError(INCORRECT_RANGE); + throw new $RangeError(INCORRECT_RANGE); } var ifIncrease = end > start; var inclusiveEnd = false; @@ -35,16 +35,16 @@ var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(sta } else if (typeof option == type) { step = option; } else { - throw $TypeError(INCORRECT_RANGE); + throw new $TypeError(INCORRECT_RANGE); } if (isNullOrUndefined(step)) { step = ifIncrease ? one : -one; } if (typeof step != type) { - throw $TypeError(INCORRECT_RANGE); + throw new $TypeError(INCORRECT_RANGE); } if (step === Infinity || step === -Infinity || (step === zero && start !== end)) { - throw $RangeError(INCORRECT_RANGE); + throw new $RangeError(INCORRECT_RANGE); } // eslint-disable-next-line no-self-compare -- NaN check var hitsEnd = start !== start || end !== end || step !== step || (end > start) !== (step > zero); diff --git a/packages/core-js/internals/object-define-property.js b/packages/core-js/internals/object-define-property.js index 072e7b6b6157..704d6166835f 100644 --- a/packages/core-js/internals/object-define-property.js +++ b/packages/core-js/internals/object-define-property.js @@ -38,7 +38,7 @@ exports.f = DESCRIPTORS ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P if (IE8_DOM_DEFINE) try { return $defineProperty(O, P, Attributes); } catch (error) { /* empty */ } - if ('get' in Attributes || 'set' in Attributes) throw $TypeError('Accessors not supported'); + if ('get' in Attributes || 'set' in Attributes) throw new $TypeError('Accessors not supported'); if ('value' in Attributes) O[P] = Attributes.value; return O; }; diff --git a/packages/core-js/internals/ordinary-to-primitive.js b/packages/core-js/internals/ordinary-to-primitive.js index 42594fe4d8f5..f8acc2faeb06 100644 --- a/packages/core-js/internals/ordinary-to-primitive.js +++ b/packages/core-js/internals/ordinary-to-primitive.js @@ -12,5 +12,5 @@ module.exports = function (input, pref) { if (pref === 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; if (isCallable(fn = input.valueOf) && !isObject(val = call(fn, input))) return val; if (pref !== 'string' && isCallable(fn = input.toString) && !isObject(val = call(fn, input))) return val; - throw $TypeError("Can't convert object to primitive value"); + throw new $TypeError("Can't convert object to primitive value"); }; diff --git a/packages/core-js/internals/parse-json-string.js b/packages/core-js/internals/parse-json-string.js index 8a8055cd7884..741c0bd81018 100644 --- a/packages/core-js/internals/parse-json-string.js +++ b/packages/core-js/internals/parse-json-string.js @@ -37,20 +37,20 @@ module.exports = function (source, i) { } else if (twoChars === '\\u') { i += 2; var fourHexDigits = slice(source, i, i + 4); - if (!exec(IS_4_HEX_DIGITS, fourHexDigits)) throw $SyntaxError('Bad Unicode escape at: ' + i); + if (!exec(IS_4_HEX_DIGITS, fourHexDigits)) throw new $SyntaxError('Bad Unicode escape at: ' + i); value += fromCharCode($parseInt(fourHexDigits, 16)); i += 4; - } else throw $SyntaxError('Unknown escape sequence: "' + twoChars + '"'); + } else throw new $SyntaxError('Unknown escape sequence: "' + twoChars + '"'); } else if (chr === '"') { unterminated = false; i++; break; } else { - if (exec(IS_C0_CONTROL_CODE, chr)) throw $SyntaxError('Bad control character in string literal at: ' + i); + if (exec(IS_C0_CONTROL_CODE, chr)) throw new $SyntaxError('Bad control character in string literal at: ' + i); value += chr; i++; } } - if (unterminated) throw $SyntaxError('Unterminated string at: ' + i); + if (unterminated) throw new $SyntaxError('Unterminated string at: ' + i); return { value: value, end: i }; }; diff --git a/packages/core-js/internals/regexp-exec-abstract.js b/packages/core-js/internals/regexp-exec-abstract.js index 9b1391c30857..630d605644ba 100644 --- a/packages/core-js/internals/regexp-exec-abstract.js +++ b/packages/core-js/internals/regexp-exec-abstract.js @@ -17,5 +17,5 @@ module.exports = function (R, S) { return result; } if (classof(R) === 'RegExp') return call(regexpExec, R, S); - throw $TypeError('RegExp#exec called on incompatible receiver'); + throw new $TypeError('RegExp#exec called on incompatible receiver'); }; diff --git a/packages/core-js/internals/require-object-coercible.js b/packages/core-js/internals/require-object-coercible.js index f96ba645902f..2a170586e8ea 100644 --- a/packages/core-js/internals/require-object-coercible.js +++ b/packages/core-js/internals/require-object-coercible.js @@ -6,6 +6,6 @@ var $TypeError = TypeError; // `RequireObjectCoercible` abstract operation // https://tc39.es/ecma262/#sec-requireobjectcoercible module.exports = function (it) { - if (isNullOrUndefined(it)) throw $TypeError("Can't call method on " + it); + if (isNullOrUndefined(it)) throw new $TypeError("Can't call method on " + it); return it; }; diff --git a/packages/core-js/internals/string-cooked.js b/packages/core-js/internals/string-cooked.js index 488633c9a845..c0b58ea957fe 100644 --- a/packages/core-js/internals/string-cooked.js +++ b/packages/core-js/internals/string-cooked.js @@ -19,7 +19,7 @@ module.exports = function cooked(template /* , ...substitutions */) { var i = 0; while (true) { var nextVal = cookedTemplate[i++]; - if (nextVal === undefined) throw $TypeError('Incorrect template'); + if (nextVal === undefined) throw new $TypeError('Incorrect template'); push(elements, toString(nextVal)); if (i === literalSegments) return join(elements, ''); if (i < argumentsLength) push(elements, toString(arguments[i])); diff --git a/packages/core-js/internals/string-punycode-to-ascii.js b/packages/core-js/internals/string-punycode-to-ascii.js index 4a1df6e0cee8..6e397462e206 100644 --- a/packages/core-js/internals/string-punycode-to-ascii.js +++ b/packages/core-js/internals/string-punycode-to-ascii.js @@ -131,7 +131,7 @@ var encode = function (input) { // Increase `delta` enough to advance the decoder's state to , but guard against overflow. var handledCPCountPlusOne = handledCPCount + 1; if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { - throw $RangeError(OVERFLOW_ERROR); + throw new $RangeError(OVERFLOW_ERROR); } delta += (m - n) * handledCPCountPlusOne; @@ -140,7 +140,7 @@ var encode = function (input) { for (i = 0; i < input.length; i++) { currentValue = input[i]; if (currentValue < n && ++delta > maxInt) { - throw $RangeError(OVERFLOW_ERROR); + throw new $RangeError(OVERFLOW_ERROR); } if (currentValue === n) { // Represent delta as a generalized variable-length integer. diff --git a/packages/core-js/internals/string-repeat.js b/packages/core-js/internals/string-repeat.js index c8ae3ed42cf1..5d0460e9b372 100644 --- a/packages/core-js/internals/string-repeat.js +++ b/packages/core-js/internals/string-repeat.js @@ -11,7 +11,7 @@ module.exports = function repeat(count) { var str = toString(requireObjectCoercible(this)); var result = ''; var n = toIntegerOrInfinity(count); - if (n < 0 || n === Infinity) throw $RangeError('Wrong number of repetitions'); + if (n < 0 || n === Infinity) throw new $RangeError('Wrong number of repetitions'); for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) result += str; return result; }; diff --git a/packages/core-js/internals/to-big-int.js b/packages/core-js/internals/to-big-int.js index 8e0a0db44115..4e36df998ce8 100644 --- a/packages/core-js/internals/to-big-int.js +++ b/packages/core-js/internals/to-big-int.js @@ -7,7 +7,7 @@ var $TypeError = TypeError; // https://tc39.es/ecma262/#sec-tobigint module.exports = function (argument) { var prim = toPrimitive(argument, 'number'); - if (typeof prim == 'number') throw $TypeError("Can't convert number to bigint"); + if (typeof prim == 'number') throw new $TypeError("Can't convert number to bigint"); // eslint-disable-next-line es/no-bigint -- safe return BigInt(prim); }; diff --git a/packages/core-js/internals/to-index.js b/packages/core-js/internals/to-index.js index 03bc0d133fb3..63333818b65a 100644 --- a/packages/core-js/internals/to-index.js +++ b/packages/core-js/internals/to-index.js @@ -10,6 +10,6 @@ module.exports = function (it) { if (it === undefined) return 0; var number = toIntegerOrInfinity(it); var length = toLength(number); - if (number !== length) throw $RangeError('Wrong length or index'); + if (number !== length) throw new $RangeError('Wrong length or index'); return length; }; diff --git a/packages/core-js/internals/to-offset.js b/packages/core-js/internals/to-offset.js index d3e1b7302e07..7376f6fc04b9 100644 --- a/packages/core-js/internals/to-offset.js +++ b/packages/core-js/internals/to-offset.js @@ -5,6 +5,6 @@ var $RangeError = RangeError; module.exports = function (it, BYTES) { var offset = toPositiveInteger(it); - if (offset % BYTES) throw $RangeError('Wrong offset'); + if (offset % BYTES) throw new $RangeError('Wrong offset'); return offset; }; diff --git a/packages/core-js/internals/to-positive-integer.js b/packages/core-js/internals/to-positive-integer.js index 606d486022b9..5376f5191f6b 100644 --- a/packages/core-js/internals/to-positive-integer.js +++ b/packages/core-js/internals/to-positive-integer.js @@ -5,6 +5,6 @@ var $RangeError = RangeError; module.exports = function (it) { var result = toIntegerOrInfinity(it); - if (result < 0) throw $RangeError("The argument can't be less than 0"); + if (result < 0) throw new $RangeError("The argument can't be less than 0"); return result; }; diff --git a/packages/core-js/internals/to-primitive.js b/packages/core-js/internals/to-primitive.js index 04b65aa4f60f..a75184388996 100644 --- a/packages/core-js/internals/to-primitive.js +++ b/packages/core-js/internals/to-primitive.js @@ -19,7 +19,7 @@ module.exports = function (input, pref) { if (pref === undefined) pref = 'default'; result = call(exoticToPrim, input, pref); if (!isObject(result) || isSymbol(result)) return result; - throw $TypeError("Can't convert object to primitive value"); + throw new $TypeError("Can't convert object to primitive value"); } if (pref === undefined) pref = 'number'; return ordinaryToPrimitive(input, pref); diff --git a/packages/core-js/internals/to-string.js b/packages/core-js/internals/to-string.js index 7ced615f11b6..0b0fae5e67c0 100644 --- a/packages/core-js/internals/to-string.js +++ b/packages/core-js/internals/to-string.js @@ -4,6 +4,6 @@ var classof = require('../internals/classof'); var $String = String; module.exports = function (argument) { - if (classof(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); + if (classof(argument) === 'Symbol') throw new TypeError('Cannot convert a Symbol value to a string'); return $String(argument); }; diff --git a/packages/core-js/internals/typed-array-constructor.js b/packages/core-js/internals/typed-array-constructor.js index 13c1f85b25f4..92ca9f581b7b 100644 --- a/packages/core-js/internals/typed-array-constructor.js +++ b/packages/core-js/internals/typed-array-constructor.js @@ -167,12 +167,12 @@ if (DESCRIPTORS) { byteOffset = toOffset(offset, BYTES); var $len = data.byteLength; if ($length === undefined) { - if ($len % BYTES) throw RangeError(WRONG_LENGTH); + if ($len % BYTES) throw new RangeError(WRONG_LENGTH); byteLength = $len - byteOffset; - if (byteLength < 0) throw RangeError(WRONG_LENGTH); + if (byteLength < 0) throw new RangeError(WRONG_LENGTH); } else { byteLength = toLength($length) * BYTES; - if (byteLength + byteOffset > $len) throw RangeError(WRONG_LENGTH); + if (byteLength + byteOffset > $len) throw new RangeError(WRONG_LENGTH); } length = byteLength / BYTES; } else if (isTypedArray(data)) { diff --git a/packages/core-js/internals/validate-arguments-length.js b/packages/core-js/internals/validate-arguments-length.js index 02daf0650fa4..b3a67b1a54fe 100644 --- a/packages/core-js/internals/validate-arguments-length.js +++ b/packages/core-js/internals/validate-arguments-length.js @@ -2,6 +2,6 @@ var $TypeError = TypeError; module.exports = function (passed, required) { - if (passed < required) throw $TypeError('Not enough arguments'); + if (passed < required) throw new $TypeError('Not enough arguments'); return passed; }; diff --git a/packages/core-js/modules/es.aggregate-error.constructor.js b/packages/core-js/modules/es.aggregate-error.constructor.js index 63381a843a46..0d76dd02e50d 100644 --- a/packages/core-js/modules/es.aggregate-error.constructor.js +++ b/packages/core-js/modules/es.aggregate-error.constructor.js @@ -21,7 +21,7 @@ var $AggregateError = function AggregateError(errors, message /* , options */) { var isInstance = isPrototypeOf(AggregateErrorPrototype, this); var that; if (setPrototypeOf) { - that = setPrototypeOf($Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype); + that = setPrototypeOf(new $Error(), isInstance ? getPrototypeOf(this) : AggregateErrorPrototype); } else { that = isInstance ? this : create(AggregateErrorPrototype); createNonEnumerableProperty(that, TO_STRING_TAG, 'Error'); diff --git a/packages/core-js/modules/es.error.cause.js b/packages/core-js/modules/es.error.cause.js index ce169b7d4d5b..1aa11d0e36a4 100644 --- a/packages/core-js/modules/es.error.cause.js +++ b/packages/core-js/modules/es.error.cause.js @@ -8,7 +8,8 @@ var wrapErrorConstructorWithCause = require('../internals/wrap-error-constructor var WEB_ASSEMBLY = 'WebAssembly'; var WebAssembly = global[WEB_ASSEMBLY]; -var FORCED = Error('e', { cause: 7 }).cause !== 7; +// eslint-disable-next-line es/no-error-cause -- feature detection +var FORCED = new Error('e', { cause: 7 }).cause !== 7; var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) { var O = {}; diff --git a/packages/core-js/modules/es.number.constructor.js b/packages/core-js/modules/es.number.constructor.js index ce6ab0b06a8d..975159b4c3f2 100644 --- a/packages/core-js/modules/es.number.constructor.js +++ b/packages/core-js/modules/es.number.constructor.js @@ -38,7 +38,7 @@ var toNumeric = function (value) { var toNumber = function (argument) { var it = toPrimitive(argument, 'number'); var first, third, radix, maxCode, digits, length, index, code; - if (isSymbol(it)) throw TypeError('Cannot convert a Symbol value to a number'); + if (isSymbol(it)) throw new TypeError('Cannot convert a Symbol value to a number'); if (typeof it == 'string' && it.length > 2) { it = trim(it); first = charCodeAt(it, 0); diff --git a/packages/core-js/modules/es.number.to-exponential.js b/packages/core-js/modules/es.number.to-exponential.js index 597938d22517..47ca23bee883 100644 --- a/packages/core-js/modules/es.number.to-exponential.js +++ b/packages/core-js/modules/es.number.to-exponential.js @@ -55,7 +55,7 @@ $({ target: 'Number', proto: true, forced: FORCED }, { var f = toIntegerOrInfinity(fractionDigits); if (!$isFinite(x)) return String(x); // TODO: ES2018 increased the maximum number of fraction digits to 100, need to improve the implementation - if (f < 0 || f > 20) throw $RangeError('Incorrect fraction digits'); + if (f < 0 || f > 20) throw new $RangeError('Incorrect fraction digits'); if (ROUNDS_PROPERLY) return nativeToExponential(x, f); var s = ''; var m = ''; diff --git a/packages/core-js/modules/es.number.to-fixed.js b/packages/core-js/modules/es.number.to-fixed.js index c7b7c99a5ab1..2ac36b033ca5 100644 --- a/packages/core-js/modules/es.number.to-fixed.js +++ b/packages/core-js/modules/es.number.to-fixed.js @@ -83,7 +83,7 @@ $({ target: 'Number', proto: true, forced: FORCED }, { var e, z, j, k; // TODO: ES2018 increased the maximum number of fraction digits to 100, need to improve the implementation - if (fractDigits < 0 || fractDigits > 20) throw $RangeError('Incorrect fraction digits'); + if (fractDigits < 0 || fractDigits > 20) throw new $RangeError('Incorrect fraction digits'); // eslint-disable-next-line no-self-compare -- NaN check if (number !== number) return 'NaN'; if (number <= -1e21 || number >= 1e21) return $String(number); diff --git a/packages/core-js/modules/es.promise.constructor.js b/packages/core-js/modules/es.promise.constructor.js index 3468f7cfcc20..44a8017ee18d 100644 --- a/packages/core-js/modules/es.promise.constructor.js +++ b/packages/core-js/modules/es.promise.constructor.js @@ -79,7 +79,7 @@ var callReaction = function (reaction, state) { } } if (result === reaction.promise) { - reject(TypeError('Promise-chain cycle')); + reject(new TypeError('Promise-chain cycle')); } else if (then = isThenable(result)) { call(then, result, resolve, reject); } else resolve(result); @@ -169,7 +169,7 @@ var internalResolve = function (state, value, unwrap) { state.done = true; if (unwrap) state = unwrap; try { - if (state.facade === value) throw TypeError("Promise can't be resolved itself"); + if (state.facade === value) throw new TypeError("Promise can't be resolved itself"); var then = isThenable(value); if (then) { microtask(function () { diff --git a/packages/core-js/modules/es.regexp.dot-all.js b/packages/core-js/modules/es.regexp.dot-all.js index cca3eb48c38b..43c3a8d49dd7 100644 --- a/packages/core-js/modules/es.regexp.dot-all.js +++ b/packages/core-js/modules/es.regexp.dot-all.js @@ -20,7 +20,7 @@ if (DESCRIPTORS && UNSUPPORTED_DOT_ALL) { if (classof(this) === 'RegExp') { return !!getInternalState(this).dotAll; } - throw $TypeError('Incompatible receiver, RegExp required'); + throw new $TypeError('Incompatible receiver, RegExp required'); } }); } diff --git a/packages/core-js/modules/es.regexp.sticky.js b/packages/core-js/modules/es.regexp.sticky.js index 78fe7bbc6eea..7a7d2bd43373 100644 --- a/packages/core-js/modules/es.regexp.sticky.js +++ b/packages/core-js/modules/es.regexp.sticky.js @@ -20,7 +20,7 @@ if (DESCRIPTORS && MISSED_STICKY) { if (classof(this) === 'RegExp') { return !!getInternalState(this).sticky; } - throw $TypeError('Incompatible receiver, RegExp required'); + throw new $TypeError('Incompatible receiver, RegExp required'); } }); } diff --git a/packages/core-js/modules/es.string.from-code-point.js b/packages/core-js/modules/es.string.from-code-point.js index 9d7bfa44fa6d..112f39aa6d63 100644 --- a/packages/core-js/modules/es.string.from-code-point.js +++ b/packages/core-js/modules/es.string.from-code-point.js @@ -23,7 +23,7 @@ $({ target: 'String', stat: true, arity: 1, forced: INCORRECT_LENGTH }, { var code; while (length > i) { code = +arguments[i++]; - if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw $RangeError(code + ' is not a valid code point'); + if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw new $RangeError(code + ' is not a valid code point'); elements[i] = code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00); diff --git a/packages/core-js/modules/es.string.match-all.js b/packages/core-js/modules/es.string.match-all.js index 3584dbfb19ef..3d1cce10c441 100644 --- a/packages/core-js/modules/es.string.match-all.js +++ b/packages/core-js/modules/es.string.match-all.js @@ -86,7 +86,7 @@ $({ target: 'String', proto: true, forced: WORKS_WITH_NON_GLOBAL_REGEX }, { if (!isNullOrUndefined(regexp)) { if (isRegExp(regexp)) { flags = toString(requireObjectCoercible(getRegExpFlags(regexp))); - if (!~stringIndexOf(flags, 'g')) throw $TypeError('`.matchAll` does not allow non-global regexes'); + if (!~stringIndexOf(flags, 'g')) throw new $TypeError('`.matchAll` does not allow non-global regexes'); } if (WORKS_WITH_NON_GLOBAL_REGEX) return nativeMatchAll(O, regexp); matcher = getMethod(regexp, MATCH_ALL); diff --git a/packages/core-js/modules/es.string.replace-all.js b/packages/core-js/modules/es.string.replace-all.js index 57f05ca21a3a..ddaf64e26212 100644 --- a/packages/core-js/modules/es.string.replace-all.js +++ b/packages/core-js/modules/es.string.replace-all.js @@ -39,7 +39,7 @@ $({ target: 'String', proto: true }, { IS_REG_EXP = isRegExp(searchValue); if (IS_REG_EXP) { flags = toString(requireObjectCoercible(getRegExpFlags(searchValue))); - if (!~indexOf(flags, 'g')) throw $TypeError('`.replaceAll` does not allow non-global regexes'); + if (!~indexOf(flags, 'g')) throw new $TypeError('`.replaceAll` does not allow non-global regexes'); } replacer = getMethod(searchValue, REPLACE); if (replacer) { diff --git a/packages/core-js/modules/es.symbol.constructor.js b/packages/core-js/modules/es.symbol.constructor.js index 9450fdfc6375..4f91093ac00a 100644 --- a/packages/core-js/modules/es.symbol.constructor.js +++ b/packages/core-js/modules/es.symbol.constructor.js @@ -161,7 +161,7 @@ var $getOwnPropertySymbols = function (O) { // https://tc39.es/ecma262/#sec-symbol-constructor if (!NATIVE_SYMBOL) { $Symbol = function Symbol() { - if (isPrototypeOf(SymbolPrototype, this)) throw TypeError('Symbol is not a constructor'); + if (isPrototypeOf(SymbolPrototype, this)) throw new TypeError('Symbol is not a constructor'); var description = !arguments.length || arguments[0] === undefined ? undefined : $toString(arguments[0]); var tag = uid(description); var setter = function (value) { diff --git a/packages/core-js/modules/es.symbol.key-for.js b/packages/core-js/modules/es.symbol.key-for.js index 87d090e378d6..c7f4d25cc8f7 100644 --- a/packages/core-js/modules/es.symbol.key-for.js +++ b/packages/core-js/modules/es.symbol.key-for.js @@ -12,7 +12,7 @@ var SymbolToStringRegistry = shared('symbol-to-string-registry'); // https://tc39.es/ecma262/#sec-symbol.keyfor $({ target: 'Symbol', stat: true, forced: !NATIVE_SYMBOL_REGISTRY }, { keyFor: function keyFor(sym) { - if (!isSymbol(sym)) throw TypeError(tryToString(sym) + ' is not a symbol'); + if (!isSymbol(sym)) throw new TypeError(tryToString(sym) + ' is not a symbol'); if (hasOwn(SymbolToStringRegistry, sym)) return SymbolToStringRegistry[sym]; } }); diff --git a/packages/core-js/modules/es.typed-array.set.js b/packages/core-js/modules/es.typed-array.set.js index b658ef914db6..ec89248c431a 100644 --- a/packages/core-js/modules/es.typed-array.set.js +++ b/packages/core-js/modules/es.typed-array.set.js @@ -39,6 +39,6 @@ exportTypedArrayMethod('set', function set(arrayLike /* , offset */) { var length = this.length; var len = lengthOfArrayLike(src); var index = 0; - if (len + offset > length) throw RangeError('Wrong length'); + if (len + offset > length) throw new RangeError('Wrong length'); while (index < len) this[offset + index] = src[index++]; }, !WORKS_WITH_OBJECTS_AND_GENERIC_ON_TYPED_ARRAYS || TO_OBJECT_BUG); diff --git a/packages/core-js/modules/esnext.async-disposable-stack.constructor.js b/packages/core-js/modules/esnext.async-disposable-stack.constructor.js index 80e3c179f02e..0b9ca3939139 100644 --- a/packages/core-js/modules/esnext.async-disposable-stack.constructor.js +++ b/packages/core-js/modules/esnext.async-disposable-stack.constructor.js @@ -29,7 +29,7 @@ var PENDING = 'pending'; var getPendingAsyncDisposableStackInternalState = function (stack) { var internalState = getAsyncDisposableStackInternalState(stack); - if (internalState.state === DISPOSED) throw $ReferenceError(ASYNC_DISPOSABLE_STACK + ' already disposed'); + if (internalState.state === DISPOSED) throw new $ReferenceError(ASYNC_DISPOSABLE_STACK + ' already disposed'); return internalState; }; diff --git a/packages/core-js/modules/esnext.async-iterator.constructor.js b/packages/core-js/modules/esnext.async-iterator.constructor.js index 010bf05a74a8..b82b37369fe4 100644 --- a/packages/core-js/modules/esnext.async-iterator.constructor.js +++ b/packages/core-js/modules/esnext.async-iterator.constructor.js @@ -14,7 +14,7 @@ var $TypeError = TypeError; var AsyncIteratorConstructor = function AsyncIterator() { anInstance(this, AsyncIteratorPrototype); - if (getPrototypeOf(this) === AsyncIteratorPrototype) throw $TypeError('Abstract class AsyncIterator not directly constructable'); + if (getPrototypeOf(this) === AsyncIteratorPrototype) throw new $TypeError('Abstract class AsyncIterator not directly constructable'); }; AsyncIteratorConstructor.prototype = AsyncIteratorPrototype; diff --git a/packages/core-js/modules/esnext.async-iterator.reduce.js b/packages/core-js/modules/esnext.async-iterator.reduce.js index 0764aa2f4bfc..b417a51d26ab 100644 --- a/packages/core-js/modules/esnext.async-iterator.reduce.js +++ b/packages/core-js/modules/esnext.async-iterator.reduce.js @@ -34,7 +34,7 @@ $({ target: 'AsyncIterator', proto: true, real: true }, { Promise.resolve(anObject(call(next, iterator))).then(function (step) { try { if (anObject(step).done) { - noInitial ? reject($TypeError('Reduce of empty iterator with no initial value')) : resolve(accumulator); + noInitial ? reject(new $TypeError('Reduce of empty iterator with no initial value')) : resolve(accumulator); } else { var value = step.value; if (noInitial) { diff --git a/packages/core-js/modules/esnext.data-view.set-float16.js b/packages/core-js/modules/esnext.data-view.set-float16.js index 28e281ff7e3f..97d71d55ad13 100644 --- a/packages/core-js/modules/esnext.data-view.set-float16.js +++ b/packages/core-js/modules/esnext.data-view.set-float16.js @@ -13,7 +13,7 @@ var setUint16 = uncurryThis(DataView.prototype.setUint16); // https://github.com/tc39/proposal-float16array $({ target: 'DataView', proto: true }, { setFloat16: function setFloat16(byteOffset, value /* , littleEndian */) { - if (classof(this) !== 'DataView') throw $TypeError('Incorrect receiver'); + if (classof(this) !== 'DataView') throw new $TypeError('Incorrect receiver'); var offset = toIndex(byteOffset); var bytes = packIEEE754(+value, 10, 2); return setUint16(this, offset, bytes[1] << 8 | bytes[0], arguments.length > 2 ? arguments[2] : false); diff --git a/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js b/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js index 56053c1f0182..5b3de68d531f 100644 --- a/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js +++ b/packages/core-js/modules/esnext.data-view.set-uint8-clamped.js @@ -13,7 +13,7 @@ var setUint8 = uncurryThis(DataView.prototype.setUint8); // https://github.com/tc39/proposal-dataview-get-set-uint8c $({ target: 'DataView', proto: true, forced: true }, { setUint8Clamped: function setUint8Clamped(byteOffset, value) { - if (classof(this) !== 'DataView') throw $TypeError('Incorrect receiver'); + if (classof(this) !== 'DataView') throw new $TypeError('Incorrect receiver'); var offset = toIndex(byteOffset); return setUint8(this, offset, toUint8Clamped(value)); } diff --git a/packages/core-js/modules/esnext.disposable-stack.constructor.js b/packages/core-js/modules/esnext.disposable-stack.constructor.js index 2023cbe4be54..435e21f6a24c 100644 --- a/packages/core-js/modules/esnext.disposable-stack.constructor.js +++ b/packages/core-js/modules/esnext.disposable-stack.constructor.js @@ -28,7 +28,7 @@ var PENDING = 'pending'; var getPendingDisposableStackInternalState = function (stack) { var internalState = getDisposableStackInternalState(stack); - if (internalState.state === DISPOSED) throw $ReferenceError(DISPOSABLE_STACK + ' already disposed'); + if (internalState.state === DISPOSED) throw new $ReferenceError(DISPOSABLE_STACK + ' already disposed'); return internalState; }; diff --git a/packages/core-js/modules/esnext.iterator.constructor.js b/packages/core-js/modules/esnext.iterator.constructor.js index 76571d29b775..bc66c7ccceec 100644 --- a/packages/core-js/modules/esnext.iterator.constructor.js +++ b/packages/core-js/modules/esnext.iterator.constructor.js @@ -25,7 +25,7 @@ var FORCED = IS_PURE var IteratorConstructor = function Iterator() { anInstance(this, IteratorPrototype); - if (getPrototypeOf(this) === IteratorPrototype) throw $TypeError('Abstract class Iterator not directly constructable'); + if (getPrototypeOf(this) === IteratorPrototype) throw new $TypeError('Abstract class Iterator not directly constructable'); }; if (!hasOwn(IteratorPrototype, TO_STRING_TAG)) { diff --git a/packages/core-js/modules/esnext.iterator.range.js b/packages/core-js/modules/esnext.iterator.range.js index 3e79829b6086..876940b1f32a 100644 --- a/packages/core-js/modules/esnext.iterator.range.js +++ b/packages/core-js/modules/esnext.iterator.range.js @@ -11,6 +11,6 @@ $({ target: 'Iterator', stat: true, forced: true }, { range: function range(start, end, option) { if (typeof start == 'number') return new NumericRangeIterator(start, end, option, 'number', 0, 1); if (typeof start == 'bigint') return new NumericRangeIterator(start, end, option, 'bigint', BigInt(0), BigInt(1)); - throw $TypeError('Incorrect Iterator.range arguments'); + throw new $TypeError('Incorrect Iterator.range arguments'); } }); diff --git a/packages/core-js/modules/esnext.iterator.reduce.js b/packages/core-js/modules/esnext.iterator.reduce.js index 4c011e93d24f..6516a4b97df7 100644 --- a/packages/core-js/modules/esnext.iterator.reduce.js +++ b/packages/core-js/modules/esnext.iterator.reduce.js @@ -26,7 +26,7 @@ $({ target: 'Iterator', proto: true, real: true }, { } counter++; }, { IS_RECORD: true }); - if (noInitial) throw $TypeError('Reduce of empty iterator with no initial value'); + if (noInitial) throw new $TypeError('Reduce of empty iterator with no initial value'); return accumulator; } }); diff --git a/packages/core-js/modules/esnext.json.parse.js b/packages/core-js/modules/esnext.json.parse.js index 9f4c975e072c..f2b22cd7c279 100644 --- a/packages/core-js/modules/esnext.json.parse.js +++ b/packages/core-js/modules/esnext.json.parse.js @@ -43,7 +43,7 @@ var $parse = function (source, reviver) { var value = root.value; var endIndex = context.skip(IS_WHITESPACE, root.end); if (endIndex < source.length) { - throw SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex); + throw new SyntaxError('Unexpected extra character: "' + at(source, endIndex) + '" after the parsed data at: ' + endIndex); } return isCallable(reviver) ? internalize({ '': value }, '', reviver, root) : value; }; @@ -119,7 +119,7 @@ Context.prototype = { return fork.keyword(false); case 'n': return fork.keyword(null); - } throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i); + } throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i); }, node: function (type, value, start, end, nodes) { return new Node(value, end, type ? null : slice(this.source, start, end), nodes); @@ -196,14 +196,14 @@ Context.prototype = { if (at(source, i) === '-') i++; if (at(source, i) === '0') i++; else if (exec(IS_NON_ZERO_DIGIT, at(source, i))) i = this.skip(IS_DIGIT, ++i); - else throw SyntaxError('Failed to parse number at: ' + i); + else throw new SyntaxError('Failed to parse number at: ' + i); if (at(source, i) === '.') i = this.skip(IS_DIGIT, ++i); if (at(source, i) === 'e' || at(source, i) === 'E') { i++; if (at(source, i) === '+' || at(source, i) === '-') i++; var exponentStartIndex = i; i = this.skip(IS_DIGIT, i); - if (exponentStartIndex === i) throw SyntaxError("Failed to parse number's exponent value at: " + i); + if (exponentStartIndex === i) throw new SyntaxError("Failed to parse number's exponent value at: " + i); } return this.node(PRIMITIVE, Number(slice(source, startIndex, i)), startIndex, i); }, @@ -211,7 +211,7 @@ Context.prototype = { var keyword = '' + value; var index = this.index; var endIndex = index + keyword.length; - if (slice(this.source, index, endIndex) !== keyword) throw SyntaxError('Failed to parse value at: ' + index); + if (slice(this.source, index, endIndex) !== keyword) throw new SyntaxError('Failed to parse value at: ' + index); return this.node(PRIMITIVE, value, index, endIndex); }, skip: function (regex, i) { @@ -223,7 +223,7 @@ Context.prototype = { i = this.skip(IS_WHITESPACE, i); var chr = at(this.source, i); for (var j = 0; j < array.length; j++) if (array[j] === chr) return i; - throw SyntaxError('Unexpected character: "' + chr + '" at: ' + i); + throw new SyntaxError('Unexpected character: "' + chr + '" at: ' + i); } }; diff --git a/packages/core-js/modules/esnext.json.raw-json.js b/packages/core-js/modules/esnext.json.raw-json.js index 48cbf4222ec1..bb249d95b7fd 100644 --- a/packages/core-js/modules/esnext.json.raw-json.js +++ b/packages/core-js/modules/esnext.json.raw-json.js @@ -37,10 +37,10 @@ $({ target: 'JSON', stat: true, forced: !NATIVE_RAW_JSON }, { rawJSON: function rawJSON(text) { var jsonString = toString(text); if (jsonString === '' || exec(IS_WHITESPACE, at(jsonString, 0)) || exec(IS_WHITESPACE, at(jsonString, jsonString.length - 1))) { - throw $SyntaxError(ERROR_MESSAGE); + throw new $SyntaxError(ERROR_MESSAGE); } var parsed = parse(jsonString); - if (typeof parsed == 'object' && parsed !== null) throw $SyntaxError(ERROR_MESSAGE); + if (typeof parsed == 'object' && parsed !== null) throw new $SyntaxError(ERROR_MESSAGE); var obj = create(null); setInternalState(obj, { type: 'RawJSON' }); createProperty(obj, 'rawJSON', jsonString); diff --git a/packages/core-js/modules/esnext.map.reduce.js b/packages/core-js/modules/esnext.map.reduce.js index d6ab3b430b0d..1067337e337e 100644 --- a/packages/core-js/modules/esnext.map.reduce.js +++ b/packages/core-js/modules/esnext.map.reduce.js @@ -22,7 +22,7 @@ $({ target: 'Map', proto: true, real: true, forced: true }, { accumulator = callbackfn(accumulator, value, key, map); } }); - if (noInitial) throw $TypeError('Reduce of empty map with no initial value'); + if (noInitial) throw new $TypeError('Reduce of empty map with no initial value'); return accumulator; } }); diff --git a/packages/core-js/modules/esnext.map.update.js b/packages/core-js/modules/esnext.map.update.js index b2ac2e815a07..a112f7118c44 100644 --- a/packages/core-js/modules/esnext.map.update.js +++ b/packages/core-js/modules/esnext.map.update.js @@ -18,7 +18,7 @@ $({ target: 'Map', proto: true, real: true, forced: true }, { aCallable(callback); var isPresentInMap = has(map, key); if (!isPresentInMap && length < 3) { - throw $TypeError('Updating absent value'); + throw new $TypeError('Updating absent value'); } var value = isPresentInMap ? get(map, key) : aCallable(length > 2 ? arguments[2] : undefined)(key, map); set(map, key, callback(value, key, map)); diff --git a/packages/core-js/modules/esnext.math.seeded-prng.js b/packages/core-js/modules/esnext.math.seeded-prng.js index 44dc02f7fabf..3ca520dea4ce 100644 --- a/packages/core-js/modules/esnext.math.seeded-prng.js +++ b/packages/core-js/modules/esnext.math.seeded-prng.js @@ -30,7 +30,7 @@ var $SeededRandomGenerator = createIteratorConstructor(function SeededRandomGene $({ target: 'Math', stat: true, forced: true }, { seededPRNG: function seededPRNG(it) { var seed = anObject(it).seed; - if (!numberIsFinite(seed)) throw $TypeError(SEED_TYPE_ERROR); + if (!numberIsFinite(seed)) throw new $TypeError(SEED_TYPE_ERROR); return new $SeededRandomGenerator(seed); } }); diff --git a/packages/core-js/modules/esnext.number.from-string.js b/packages/core-js/modules/esnext.number.from-string.js index de649a42e2bd..d29c4c9c2782 100644 --- a/packages/core-js/modules/esnext.number.from-string.js +++ b/packages/core-js/modules/esnext.number.from-string.js @@ -21,17 +21,17 @@ $({ target: 'Number', stat: true, forced: true }, { fromString: function fromString(string, radix) { var sign = 1; var R, mathNum; - if (typeof string != 'string') throw $TypeError(INVALID_NUMBER_REPRESENTATION); - if (!string.length) throw $SyntaxError(INVALID_NUMBER_REPRESENTATION); + if (typeof string != 'string') throw new $TypeError(INVALID_NUMBER_REPRESENTATION); + if (!string.length) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION); if (charAt(string, 0) === '-') { sign = -1; string = stringSlice(string, 1); - if (!string.length) throw $SyntaxError(INVALID_NUMBER_REPRESENTATION); + if (!string.length) throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION); } R = radix === undefined ? 10 : toIntegerOrInfinity(radix); - if (R < 2 || R > 36) throw $RangeError(INVALID_RADIX); + if (R < 2 || R > 36) throw new $RangeError(INVALID_RADIX); if (!exec(valid, string) || numberToString(mathNum = parseInt(string, R), R) !== string) { - throw $SyntaxError(INVALID_NUMBER_REPRESENTATION); + throw new $SyntaxError(INVALID_NUMBER_REPRESENTATION); } return sign * mathNum; } diff --git a/packages/core-js/modules/esnext.set.reduce.js b/packages/core-js/modules/esnext.set.reduce.js index 77a95df49ea5..988af322f57c 100644 --- a/packages/core-js/modules/esnext.set.reduce.js +++ b/packages/core-js/modules/esnext.set.reduce.js @@ -22,7 +22,7 @@ $({ target: 'Set', proto: true, real: true, forced: true }, { accumulator = callbackfn(accumulator, value, value, set); } }); - if (noInitial) throw $TypeError('Reduce of empty set with no initial value'); + if (noInitial) throw new $TypeError('Reduce of empty set with no initial value'); return accumulator; } }); diff --git a/packages/core-js/modules/esnext.string.dedent.js b/packages/core-js/modules/esnext.string.dedent.js index 866980df995e..f600a91b8e00 100644 --- a/packages/core-js/modules/esnext.string.dedent.js +++ b/packages/core-js/modules/esnext.string.dedent.js @@ -47,7 +47,7 @@ var INVALID_CLOSING_LINE = 'Invalid closing line'; var dedentTemplateStringsArray = function (template) { var rawInput = template.raw; // https://github.com/tc39/proposal-string-dedent/issues/75 - if (FREEZING && !isFrozen(rawInput)) throw $TypeError('Raw template should be frozen'); + if (FREEZING && !isFrozen(rawInput)) throw new $TypeError('Raw template should be frozen'); if (globalDedentRegistry.has(rawInput)) return globalDedentRegistry.get(rawInput); var raw = dedentStringsArray(rawInput); var cookedArr = cookStrings(raw); @@ -67,12 +67,12 @@ var dedentStringsArray = function (template) { var i = 0; var lines, common, quasi, k; - if (!length) throw $TypeError(INVALID_TAG); + if (!length) throw new $TypeError(INVALID_TAG); for (; i < length; i++) { var element = t[i]; if (typeof element == 'string') blocks[i] = split(element, NEW_LINE); - else throw $TypeError(INVALID_TAG); + else throw new $TypeError(INVALID_TAG); } for (i = 0; i < length; i++) { @@ -80,13 +80,13 @@ var dedentStringsArray = function (template) { lines = blocks[i]; if (i === 0) { if (lines.length === 1 || lines[0].length > 0) { - throw $TypeError(INVALID_OPENING_LINE); + throw new $TypeError(INVALID_OPENING_LINE); } lines[1] = ''; } if (lastSplit) { if (lines.length === 1 || exec(NON_WHITESPACE, lines[lines.length - 1])) { - throw $TypeError(INVALID_CLOSING_LINE); + throw new $TypeError(INVALID_CLOSING_LINE); } lines[lines.length - 2] = ''; lines[lines.length - 1] = ''; diff --git a/packages/core-js/modules/esnext.suppressed-error.constructor.js b/packages/core-js/modules/esnext.suppressed-error.constructor.js index 17016e134c6c..1fe4919f449e 100644 --- a/packages/core-js/modules/esnext.suppressed-error.constructor.js +++ b/packages/core-js/modules/esnext.suppressed-error.constructor.js @@ -18,7 +18,7 @@ var $SuppressedError = function SuppressedError(error, suppressed, message) { var isInstance = isPrototypeOf(SuppressedErrorPrototype, this); var that; if (setPrototypeOf) { - that = setPrototypeOf($Error(), isInstance ? getPrototypeOf(this) : SuppressedErrorPrototype); + that = setPrototypeOf(new $Error(), isInstance ? getPrototypeOf(this) : SuppressedErrorPrototype); } else { that = isInstance ? this : create(SuppressedErrorPrototype); createNonEnumerableProperty(that, TO_STRING_TAG, 'Error'); diff --git a/packages/core-js/modules/web.dom-exception.constructor.js b/packages/core-js/modules/web.dom-exception.constructor.js index 84afb42392c7..319a8a117a3a 100644 --- a/packages/core-js/modules/web.dom-exception.constructor.js +++ b/packages/core-js/modules/web.dom-exception.constructor.js @@ -37,7 +37,7 @@ var NativeDOMExceptionPrototype = NativeDOMException && NativeDOMException.proto var ErrorPrototype = Error.prototype; var setInternalState = InternalStateModule.set; var getInternalState = InternalStateModule.getterFor(DOM_EXCEPTION); -var HAS_STACK = 'stack' in Error(DOM_EXCEPTION); +var HAS_STACK = 'stack' in new Error(DOM_EXCEPTION); var codeFor = function (name) { return hasOwn(DOMExceptionConstants, name) && DOMExceptionConstants[name].m ? DOMExceptionConstants[name].c : 0; @@ -61,7 +61,7 @@ var $DOMException = function DOMException() { this.code = code; } if (HAS_STACK) { - var error = Error(message); + var error = new Error(message); error.name = DOM_EXCEPTION; defineProperty(this, 'stack', createPropertyDescriptor(1, clearErrorStack(error.stack, 1))); } diff --git a/packages/core-js/modules/web.dom-exception.stack.js b/packages/core-js/modules/web.dom-exception.stack.js index 7e67e6fd18de..da347118a9c3 100644 --- a/packages/core-js/modules/web.dom-exception.stack.js +++ b/packages/core-js/modules/web.dom-exception.stack.js @@ -23,7 +23,7 @@ var $DOMException = function DOMException() { var message = normalizeStringArgument(argumentsLength < 1 ? undefined : arguments[0]); var name = normalizeStringArgument(argumentsLength < 2 ? undefined : arguments[1], 'Error'); var that = new NativeDOMException(message, name); - var error = Error(message); + var error = new Error(message); error.name = DOM_EXCEPTION; defineProperty(that, 'stack', createPropertyDescriptor(1, clearErrorStack(error.stack, 1))); inheritIfRequired(that, this, $DOMException); @@ -32,7 +32,7 @@ var $DOMException = function DOMException() { var DOMExceptionPrototype = $DOMException.prototype = NativeDOMException.prototype; -var ERROR_HAS_STACK = 'stack' in Error(DOM_EXCEPTION); +var ERROR_HAS_STACK = 'stack' in new Error(DOM_EXCEPTION); var DOM_EXCEPTION_HAS_STACK = 'stack' in new NativeDOMException(1, 2); // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe diff --git a/packages/core-js/modules/web.self.js b/packages/core-js/modules/web.self.js index a89518e9bd72..c732753f69c3 100644 --- a/packages/core-js/modules/web.self.js +++ b/packages/core-js/modules/web.self.js @@ -23,7 +23,7 @@ try { return global; }, set: function self(value) { - if (this !== global) throw $TypeError('Illegal invocation'); + if (this !== global) throw new $TypeError('Illegal invocation'); defineProperty(global, 'self', { value: value, writable: true, diff --git a/packages/core-js/modules/web.structured-clone.js b/packages/core-js/modules/web.structured-clone.js index 7277f2b61151..062f640b7643 100644 --- a/packages/core-js/modules/web.structured-clone.js +++ b/packages/core-js/modules/web.structured-clone.js @@ -230,37 +230,37 @@ var structuredCloneInternal = function (value, map, transferredBuffers) { name = value.name; switch (name) { case 'AggregateError': - cloned = getBuiltin('AggregateError')([]); + cloned = new (getBuiltin('AggregateError'))([]); break; case 'EvalError': - cloned = EvalError(); + cloned = new EvalError(); break; case 'RangeError': - cloned = RangeError(); + cloned = new RangeError(); break; case 'ReferenceError': - cloned = ReferenceError(); + cloned = new ReferenceError(); break; case 'SyntaxError': - cloned = SyntaxError(); + cloned = new SyntaxError(); break; case 'TypeError': - cloned = TypeError(); + cloned = new TypeError(); break; case 'URIError': - cloned = URIError(); + cloned = new URIError(); break; case 'CompileError': - cloned = CompileError(); + cloned = new CompileError(); break; case 'LinkError': - cloned = LinkError(); + cloned = new LinkError(); break; case 'RuntimeError': - cloned = RuntimeError(); + cloned = new RuntimeError(); break; default: - cloned = Error(); + cloned = new Error(); } break; case 'DOMException': @@ -523,7 +523,7 @@ var replacePlaceholders = function (value, map) { }; var tryToTransfer = function (rawTransfer, map) { - if (!isObject(rawTransfer)) throw TypeError('Transfer option cannot be converted to a sequence'); + if (!isObject(rawTransfer)) throw new TypeError('Transfer option cannot be converted to a sequence'); var transfer = []; diff --git a/packages/core-js/modules/web.url-search-params.constructor.js b/packages/core-js/modules/web.url-search-params.constructor.js index af7bdf590ec7..ceb75453f404 100644 --- a/packages/core-js/modules/web.url-search-params.constructor.js +++ b/packages/core-js/modules/web.url-search-params.constructor.js @@ -156,7 +156,7 @@ URLSearchParamsState.prototype = { (first = call(entryNext, entryIterator)).done || (second = call(entryNext, entryIterator)).done || !call(entryNext, entryIterator).done - ) throw TypeError('Expected sequence with length 2'); + ) throw new TypeError('Expected sequence with length 2'); push(this.entries, { key: $toString(first.value), value: $toString(second.value) }); } } else for (var key in object) if (hasOwn(object, key)) { diff --git a/packages/core-js/modules/web.url.constructor.js b/packages/core-js/modules/web.url.constructor.js index b9275895bc8e..13f9b1238ca7 100644 --- a/packages/core-js/modules/web.url.constructor.js +++ b/packages/core-js/modules/web.url.constructor.js @@ -320,12 +320,12 @@ var URLState = function (url, isBase, base) { var baseState, failure, searchParams; if (isBase) { failure = this.parse(urlString); - if (failure) throw TypeError(failure); + if (failure) throw new TypeError(failure); this.searchParams = null; } else { if (base !== undefined) baseState = new URLState(base, true); failure = this.parse(urlString, null, baseState); - if (failure) throw TypeError(failure); + if (failure) throw new TypeError(failure); searchParams = getInternalSearchParamsState(new URLSearchParams()); searchParams.bindURL(this); this.searchParams = searchParams; @@ -814,7 +814,7 @@ URLState.prototype = { // https://url.spec.whatwg.org/#dom-url-href setHref: function (href) { var failure = this.parse(href); - if (failure) throw TypeError(failure); + if (failure) throw new TypeError(failure); this.searchParams.update(); }, // https://url.spec.whatwg.org/#dom-url-origin diff --git a/tests/compat-data/tests-coverage.mjs b/tests/compat-data/tests-coverage.mjs index d37b783a64de..f4ddfebcab84 100644 --- a/tests/compat-data/tests-coverage.mjs +++ b/tests/compat-data/tests-coverage.mjs @@ -89,4 +89,4 @@ if (missed.length) { error = true; } else echo(chalk.green('adding of compat data tests not required')); -if (error) throw Error(error); +if (error) throw new Error(error); diff --git a/tests/compat/tests.js b/tests/compat/tests.js index 3c6153698682..8fbcf715a153 100644 --- a/tests/compat/tests.js +++ b/tests/compat/tests.js @@ -137,7 +137,7 @@ var SAFE_ITERATION_CLOSING_SUPPORT = function () { iteratorWithReturn[Symbol.iterator] = function () { return this; }; - Array.from(iteratorWithReturn, function () { throw Error('close'); }); + Array.from(iteratorWithReturn, function () { throw new Error('close'); }); } catch (error) { return SAFE_CLOSING; } diff --git a/tests/eslint/eslint.config.js b/tests/eslint/eslint.config.js index 5443f2a90062..3f39d146465b 100644 --- a/tests/eslint/eslint.config.js +++ b/tests/eslint/eslint.config.js @@ -628,6 +628,8 @@ const base = { 'unicorn/switch-case-braces': [ERROR, 'avoid'], // enforce consistent case for text encoding identifiers 'unicorn/text-encoding-identifier-case': ERROR, + // require `new` when throwing an error + 'unicorn/throw-new-error': ERROR, // sonarjs // collection sizes and array length comparisons should make sense diff --git a/tests/unit-global/es.array.fill.js b/tests/unit-global/es.array.fill.js index 7ca5c9cc29fd..22178cddb4d2 100644 --- a/tests/unit-global/es.array.fill.js +++ b/tests/unit-global/es.array.fill.js @@ -24,7 +24,7 @@ QUnit.test('Array#fill', assert => { length: -1, }, 0, { set() { - throw Error(); + throw new Error(); }, })), 'uses ToLength'); } diff --git a/tests/unit-global/es.json.stringify.js b/tests/unit-global/es.json.stringify.js index 4b6d0b60ca40..01701c2d617a 100644 --- a/tests/unit-global/es.json.stringify.js +++ b/tests/unit-global/es.json.stringify.js @@ -19,7 +19,7 @@ if (GLOBAL.JSON?.stringify) { const num1 = new Number(10); num1.toString = () => 'toString'; - num1.valueOf = () => { throw EvalError('should not be called'); }; + num1.valueOf = () => { throw new EvalError('should not be called'); }; assert.same(stringify({ 10: 1, toString: 2, @@ -45,7 +45,7 @@ if (GLOBAL.JSON?.stringify) { const str1 = new String('str'); str1.toString = () => 'toString'; - str1.valueOf = () => { throw EvalError('should not be called'); }; + str1.valueOf = () => { throw new EvalError('should not be called'); }; assert.same(stringify({ str: 1, toString: 2, @@ -59,7 +59,7 @@ if (GLOBAL.JSON?.stringify) { sparse[1] = 'key'; assert.same(stringify({ undefined: 1, key: 2 }, sparse), '{"key":2}', 'replacer-array-undefined-3'); - assert.throws(() => stringify({}, () => { throw EvalError('should not be called'); }), EvalError, 'replacer-function-abrupt'); + assert.throws(() => stringify({}, () => { throw new EvalError('should not be called'); }), EvalError, 'replacer-function-abrupt'); const calls = []; const b1 = [1, 2]; @@ -111,7 +111,7 @@ if (GLOBAL.JSON?.stringify) { case '1': return 2; case 'c1': return true; case 'c2': return false; - } throw EvalError('unreachable'); + } throw new EvalError('unreachable'); }), stringify({ a1: { b1: [1, 2], @@ -162,12 +162,12 @@ if (GLOBAL.JSON?.stringify) { assert.same(stringify(obj5, null, new Number(1)), stringify(obj5, null, 1), 'space-number-object-1'); const num2 = new Number(1); - num2.toString = () => { throw EvalError('should not be called'); }; + num2.toString = () => { throw new EvalError('should not be called'); }; num2.valueOf = () => 3; assert.same(stringify(obj5, null, num2), stringify(obj5, null, 3), 'space-number-object-2'); const abrupt1 = new Number(4); - abrupt1.toString = () => { throw EvalError('t262'); }; - abrupt1.valueOf = () => { throw EvalError('t262'); }; + abrupt1.toString = () => { throw new EvalError('t262'); }; + abrupt1.valueOf = () => { throw new EvalError('t262'); }; assert.throws(() => stringify(obj5, null, abrupt1), EvalError, 'space-number-object-3'); assert.same(stringify(obj5, null, new Number(-5)), stringify(obj5, null, 0), 'space-number-range-1'); @@ -179,11 +179,11 @@ if (GLOBAL.JSON?.stringify) { assert.same(stringify(obj5, null, new String('xxx')), stringify(obj5, null, 'xxx'), 'space-string-object-1'); const str2 = new String('xxx'); str2.toString = () => '---'; - str2.valueOf = () => { throw EvalError('should not be called'); }; + str2.valueOf = () => { throw new EvalError('should not be called'); }; assert.same(stringify(obj5, null, str2), stringify(obj5, null, '---'), 'space-string-object-2'); const abrupt2 = new String('xxx'); - abrupt2.toString = () => { throw EvalError('t262'); }; - abrupt2.valueOf = () => { throw EvalError('t262'); }; + abrupt2.toString = () => { throw new EvalError('t262'); }; + abrupt2.valueOf = () => { throw new EvalError('t262'); }; assert.throws(() => stringify(obj5, null, abrupt2), EvalError, 'space-string-object-3'); assert.same(stringify(obj5, null, '0123456789xxxxxxxxx'), stringify(obj5, null, '0123456789'), 'space-string-range'); @@ -250,7 +250,7 @@ if (GLOBAL.JSON?.stringify) { assert.same(stringify(['str'], (key, value) => { if (value === 'str') { const num = new Number(42); - num.toString = () => { throw EvalError('should not be called'); }; + num.toString = () => { throw new EvalError('should not be called'); }; num.valueOf = () => 2; return num; } return value; @@ -259,8 +259,8 @@ if (GLOBAL.JSON?.stringify) { key: { toJSON() { const num = new Number(3.14); - num.toString = () => { throw EvalError('t262'); }; - num.valueOf = () => { throw EvalError('t262'); }; + num.toString = () => { throw new EvalError('t262'); }; + num.valueOf = () => { throw new EvalError('t262'); }; return num; }, }, @@ -350,7 +350,7 @@ if (GLOBAL.JSON?.stringify) { toJSON() { const str = new String('str'); str.toString = () => 'toString'; - str.valueOf = () => { throw EvalError('should not be called'); }; + str.valueOf = () => { throw new EvalError('should not be called'); }; return str; }, }, @@ -358,14 +358,14 @@ if (GLOBAL.JSON?.stringify) { assert.throws(() => stringify([true], (key, value) => { if (value === true) { const str = new String('str'); - str.toString = () => { throw EvalError('t262'); }; - str.valueOf = () => { throw EvalError('t262'); }; + str.toString = () => { throw new EvalError('t262'); }; + str.valueOf = () => { throw new EvalError('t262'); }; return str; } return value; }), 'value-string-object-3'); assert.throws(() => stringify({ - toJSON() { throw EvalError('t262'); }, + toJSON() { throw new EvalError('t262'); }, }), EvalError, 'value-tojson-abrupt-1'); let callCount = 0; diff --git a/tests/unit-global/es.promise.constructor.js b/tests/unit-global/es.promise.constructor.js index c2226bf29f80..bd256cc91aa8 100644 --- a/tests/unit-global/es.promise.constructor.js +++ b/tests/unit-global/es.promise.constructor.js @@ -31,7 +31,7 @@ if (DESCRIPTORS) QUnit.test('Promise operations order', assert => { // eslint-disable-next-line unicorn/no-thenable -- required for testing then() { result += 'A'; - throw Error(); + throw new Error(); }, }); promise1.catch(() => { @@ -49,7 +49,7 @@ if (DESCRIPTORS) QUnit.test('Promise operations order', assert => { $resolve2(Object.defineProperty({}, 'then', { get() { result += 'D'; - throw Error(); + throw new Error(); }, })); result += 'E'; diff --git a/tests/unit-global/esnext.async-disposable-stack.constructor.js b/tests/unit-global/esnext.async-disposable-stack.constructor.js index bc6f6ee34ad3..f8d9422e0d4f 100644 --- a/tests/unit-global/esnext.async-disposable-stack.constructor.js +++ b/tests/unit-global/esnext.async-disposable-stack.constructor.js @@ -149,7 +149,7 @@ QUnit.test('AsyncDisposableStack#2', assert => { const stack = new AsyncDisposableStack(); stack.use({ [Symbol.asyncDispose]: () => result += '6' }); - stack.adopt({}, () => { throw Error(5); }); + stack.adopt({}, () => { throw new Error(5); }); stack.defer(() => result += '4'); stack.use({ [Symbol.asyncDispose]: () => Promise.resolve(result += '3') }); stack.adopt({}, () => Promise.resolve(result += '2')); @@ -169,7 +169,7 @@ QUnit.test('AsyncDisposableStack#3', assert => { const stack = new AsyncDisposableStack(); stack.use({ [Symbol.asyncDispose]: () => result += '6' }); - stack.adopt({}, () => { throw Error(5); }); + stack.adopt({}, () => { throw new Error(5); }); stack.defer(() => result += '4'); stack.use({ [Symbol.asyncDispose]: () => Promise.reject(Error(3)) }); stack.adopt({}, () => Promise.resolve(result += '2')); diff --git a/tests/unit-global/esnext.disposable-stack.constructor.js b/tests/unit-global/esnext.disposable-stack.constructor.js index fb7534f63141..2178bb72bf2f 100644 --- a/tests/unit-global/esnext.disposable-stack.constructor.js +++ b/tests/unit-global/esnext.disposable-stack.constructor.js @@ -136,7 +136,7 @@ QUnit.test('DisposableStack', assert => { let error2; stack2.use({ [Symbol.dispose]: () => result2 += '6' }); - stack2.adopt({}, () => { throw Error(5); }); + stack2.adopt({}, () => { throw new Error(5); }); stack2.defer(() => result2 += '4'); stack2.use({ [Symbol.dispose]: () => result2 += '3' }); stack2.adopt({}, () => result2 += '2'); @@ -157,9 +157,9 @@ QUnit.test('DisposableStack', assert => { let error3; stack3.use({ [Symbol.dispose]: () => result3 += '6' }); - stack3.adopt({}, () => { throw Error(5); }); + stack3.adopt({}, () => { throw new Error(5); }); stack3.defer(() => result3 += '4'); - stack3.use({ [Symbol.dispose]: () => { throw Error(3); } }); + stack3.use({ [Symbol.dispose]: () => { throw new Error(3); } }); stack3.adopt({}, () => result3 += '2'); stack3.defer(() => result3 += '1'); diff --git a/tests/unit-global/esnext.json.parse.js b/tests/unit-global/esnext.json.parse.js index 0db547089e1a..1eaf51d50910 100644 --- a/tests/unit-global/esnext.json.parse.js +++ b/tests/unit-global/esnext.json.parse.js @@ -146,13 +146,13 @@ QUnit.test('JSON.parse', assert => { assert.throws(() => parse({ toString: null, valueOf() { - throw EvalError('t262'); + throw new EvalError('t262'); }, }, reviver), EvalError, `text-object-abrupt-1 ${ note }`); assert.throws(() => parse({ toString() { - throw EvalError('t262'); + throw new EvalError('t262'); }, }, reviver), EvalError, `text-object-abrupt-2 ${ note }`); } @@ -215,11 +215,11 @@ QUnit.test('JSON.parse', assert => { assert.same(obj3.b, 2, 'reviver-object-non-configurable-prop-delete-3'); assert.throws(() => parse('[0,0]', function () { - defineProperty(this, '1', { get: () => { throw EvalError('t262'); } }); + defineProperty(this, '1', { get: () => { throw new EvalError('t262'); } }); }), EvalError, 'reviver-get-name-err'); } - assert.throws(() => parse('0', () => { throw EvalError('t262'); }), EvalError, 'reviver-call-err'); + assert.throws(() => parse('0', () => { throw new EvalError('t262'); }), EvalError, 'reviver-call-err'); // FF20- enumeration order issue if (keys({ k: 1, 2: 3 })[0] === '2') { diff --git a/tests/unit-global/web.url.can-parse.js b/tests/unit-global/web.url.can-parse.js index 5053bcb4fa3d..6df703aeadb4 100644 --- a/tests/unit-global/web.url.can-parse.js +++ b/tests/unit-global/web.url.can-parse.js @@ -22,6 +22,6 @@ QUnit.test('URL.canParse', assert => { assert.true(canParse('x', 'https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'), 'x, https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'); assert.throws(() => canParse(), 'no args'); - assert.throws(() => canParse({ toString() { throw Error('thrower'); } }), 'conversion thrower #1'); - assert.throws(() => canParse('q:w', { toString() { throw Error('thrower'); } }), 'conversion thrower #2'); + assert.throws(() => canParse({ toString() { throw new Error('thrower'); } }), 'conversion thrower #1'); + assert.throws(() => canParse('q:w', { toString() { throw new Error('thrower'); } }), 'conversion thrower #2'); }); diff --git a/tests/unit-pure/es.json.stringify.js b/tests/unit-pure/es.json.stringify.js index 55c77599235e..e2a54df76f45 100644 --- a/tests/unit-pure/es.json.stringify.js +++ b/tests/unit-pure/es.json.stringify.js @@ -20,7 +20,7 @@ if (GLOBAL.JSON?.stringify) { const num1 = new Number(10); num1.toString = () => 'toString'; - num1.valueOf = () => { throw EvalError('should not be called'); }; + num1.valueOf = () => { throw new EvalError('should not be called'); }; assert.same(stringify({ 10: 1, toString: 2, @@ -46,7 +46,7 @@ if (GLOBAL.JSON?.stringify) { const str1 = new String('str'); str1.toString = () => 'toString'; - str1.valueOf = () => { throw EvalError('should not be called'); }; + str1.valueOf = () => { throw new EvalError('should not be called'); }; assert.same(stringify({ str: 1, toString: 2, @@ -60,7 +60,7 @@ if (GLOBAL.JSON?.stringify) { sparse[1] = 'key'; assert.same(stringify({ undefined: 1, key: 2 }, sparse), '{"key":2}', 'replacer-array-undefined-3'); - assert.throws(() => stringify({}, () => { throw EvalError('should not be called'); }), EvalError, 'replacer-function-abrupt'); + assert.throws(() => stringify({}, () => { throw new EvalError('should not be called'); }), EvalError, 'replacer-function-abrupt'); const calls = []; const b1 = [1, 2]; @@ -112,7 +112,7 @@ if (GLOBAL.JSON?.stringify) { case '1': return 2; case 'c1': return true; case 'c2': return false; - } throw EvalError('unreachable'); + } throw new EvalError('unreachable'); }), stringify({ a1: { b1: [1, 2], @@ -163,12 +163,12 @@ if (GLOBAL.JSON?.stringify) { assert.same(stringify(obj5, null, new Number(1)), stringify(obj5, null, 1), 'space-number-object-1'); const num2 = new Number(1); - num2.toString = () => { throw EvalError('should not be called'); }; + num2.toString = () => { throw new EvalError('should not be called'); }; num2.valueOf = () => 3; assert.same(stringify(obj5, null, num2), stringify(obj5, null, 3), 'space-number-object-2'); const abrupt1 = new Number(4); - abrupt1.toString = () => { throw EvalError('t262'); }; - abrupt1.valueOf = () => { throw EvalError('t262'); }; + abrupt1.toString = () => { throw new EvalError('t262'); }; + abrupt1.valueOf = () => { throw new EvalError('t262'); }; assert.throws(() => stringify(obj5, null, abrupt1), EvalError, 'space-number-object-3'); assert.same(stringify(obj5, null, new Number(-5)), stringify(obj5, null, 0), 'space-number-range-1'); @@ -180,11 +180,11 @@ if (GLOBAL.JSON?.stringify) { assert.same(stringify(obj5, null, new String('xxx')), stringify(obj5, null, 'xxx'), 'space-string-object-1'); const str2 = new String('xxx'); str2.toString = () => '---'; - str2.valueOf = () => { throw EvalError('should not be called'); }; + str2.valueOf = () => { throw new EvalError('should not be called'); }; assert.same(stringify(obj5, null, str2), stringify(obj5, null, '---'), 'space-string-object-2'); const abrupt2 = new String('xxx'); - abrupt2.toString = () => { throw EvalError('t262'); }; - abrupt2.valueOf = () => { throw EvalError('t262'); }; + abrupt2.toString = () => { throw new EvalError('t262'); }; + abrupt2.valueOf = () => { throw new EvalError('t262'); }; assert.throws(() => stringify(obj5, null, abrupt2), EvalError, 'space-string-object-3'); assert.same(stringify(obj5, null, '0123456789xxxxxxxxx'), stringify(obj5, null, '0123456789'), 'space-string-range'); @@ -251,7 +251,7 @@ if (GLOBAL.JSON?.stringify) { assert.same(stringify(['str'], (key, value) => { if (value === 'str') { const num = new Number(42); - num.toString = () => { throw EvalError('should not be called'); }; + num.toString = () => { throw new EvalError('should not be called'); }; num.valueOf = () => 2; return num; } return value; @@ -260,8 +260,8 @@ if (GLOBAL.JSON?.stringify) { key: { toJSON() { const num = new Number(3.14); - num.toString = () => { throw EvalError('t262'); }; - num.valueOf = () => { throw EvalError('t262'); }; + num.toString = () => { throw new EvalError('t262'); }; + num.valueOf = () => { throw new EvalError('t262'); }; return num; }, }, @@ -351,7 +351,7 @@ if (GLOBAL.JSON?.stringify) { toJSON() { const str = new String('str'); str.toString = () => 'toString'; - str.valueOf = () => { throw EvalError('should not be called'); }; + str.valueOf = () => { throw new EvalError('should not be called'); }; return str; }, }, @@ -359,14 +359,14 @@ if (GLOBAL.JSON?.stringify) { assert.throws(() => stringify([true], (key, value) => { if (value === true) { const str = new String('str'); - str.toString = () => { throw EvalError('t262'); }; - str.valueOf = () => { throw EvalError('t262'); }; + str.toString = () => { throw new EvalError('t262'); }; + str.valueOf = () => { throw new EvalError('t262'); }; return str; } return value; }), 'value-string-object-3'); assert.throws(() => stringify({ - toJSON() { throw EvalError('t262'); }, + toJSON() { throw new EvalError('t262'); }, }), EvalError, 'value-tojson-abrupt-1'); let callCount = 0; diff --git a/tests/unit-pure/es.promise.constructor.js b/tests/unit-pure/es.promise.constructor.js index 68fcce130e2d..b9295783f2af 100644 --- a/tests/unit-pure/es.promise.constructor.js +++ b/tests/unit-pure/es.promise.constructor.js @@ -30,7 +30,7 @@ if (DESCRIPTORS) QUnit.test('Promise operations order', assert => { // eslint-disable-next-line unicorn/no-thenable -- required for testing then() { result += 'A'; - throw Error(); + throw new Error(); }, }); promise1.catch(() => { @@ -48,7 +48,7 @@ if (DESCRIPTORS) QUnit.test('Promise operations order', assert => { $resolve2(Object.defineProperty({}, 'then', { get() { result += 'D'; - throw Error(); + throw new Error(); }, })); result += 'E'; diff --git a/tests/unit-pure/esnext.async-disposable-stack.constructor.js b/tests/unit-pure/esnext.async-disposable-stack.constructor.js index 2c830d691651..9d5fbeb4cf83 100644 --- a/tests/unit-pure/esnext.async-disposable-stack.constructor.js +++ b/tests/unit-pure/esnext.async-disposable-stack.constructor.js @@ -148,7 +148,7 @@ QUnit.test('AsyncDisposableStack#2', assert => { const stack = new AsyncDisposableStack(); stack.use({ [Symbol.asyncDispose]: () => result += '6' }); - stack.adopt({}, () => { throw Error(5); }); + stack.adopt({}, () => { throw new Error(5); }); stack.defer(() => result += '4'); stack.use({ [Symbol.asyncDispose]: () => Promise.resolve(result += '3') }); stack.adopt({}, () => Promise.resolve(result += '2')); @@ -168,7 +168,7 @@ QUnit.test('AsyncDisposableStack#3', assert => { const stack = new AsyncDisposableStack(); stack.use({ [Symbol.asyncDispose]: () => result += '6' }); - stack.adopt({}, () => { throw Error(5); }); + stack.adopt({}, () => { throw new Error(5); }); stack.defer(() => result += '4'); stack.use({ [Symbol.asyncDispose]: () => Promise.reject(Error(3)) }); stack.adopt({}, () => Promise.resolve(result += '2')); diff --git a/tests/unit-pure/esnext.disposable-stack.constructor.js b/tests/unit-pure/esnext.disposable-stack.constructor.js index dc969d8d2eed..bf36286d74b9 100644 --- a/tests/unit-pure/esnext.disposable-stack.constructor.js +++ b/tests/unit-pure/esnext.disposable-stack.constructor.js @@ -134,7 +134,7 @@ QUnit.test('DisposableStack', assert => { let error2; stack2.use({ [Symbol.dispose]: () => result2 += '6' }); - stack2.adopt({}, () => { throw Error(5); }); + stack2.adopt({}, () => { throw new Error(5); }); stack2.defer(() => result2 += '4'); stack2.use({ [Symbol.dispose]: () => result2 += '3' }); stack2.adopt({}, () => result2 += '2'); @@ -155,9 +155,9 @@ QUnit.test('DisposableStack', assert => { let error3; stack3.use({ [Symbol.dispose]: () => result3 += '6' }); - stack3.adopt({}, () => { throw Error(5); }); + stack3.adopt({}, () => { throw new Error(5); }); stack3.defer(() => result3 += '4'); - stack3.use({ [Symbol.dispose]: () => { throw Error(3); } }); + stack3.use({ [Symbol.dispose]: () => { throw new Error(3); } }); stack3.adopt({}, () => result3 += '2'); stack3.defer(() => result3 += '1'); diff --git a/tests/unit-pure/esnext.json.parse.js b/tests/unit-pure/esnext.json.parse.js index 4e1e34050f60..6b3d50eb623a 100644 --- a/tests/unit-pure/esnext.json.parse.js +++ b/tests/unit-pure/esnext.json.parse.js @@ -148,13 +148,13 @@ QUnit.test('JSON.parse', assert => { assert.throws(() => parse({ toString: null, valueOf() { - throw EvalError('t262'); + throw new EvalError('t262'); }, }, reviver), EvalError, `text-object-abrupt-1 ${ note }`); assert.throws(() => parse({ toString() { - throw EvalError('t262'); + throw new EvalError('t262'); }, }, reviver), EvalError, `text-object-abrupt-2 ${ note }`); } @@ -217,11 +217,11 @@ QUnit.test('JSON.parse', assert => { assert.same(obj3.b, 2, 'reviver-object-non-configurable-prop-delete-3'); assert.throws(() => parse('[0,0]', function () { - defineProperty(this, '1', { get: () => { throw EvalError('t262'); } }); + defineProperty(this, '1', { get: () => { throw new EvalError('t262'); } }); }), EvalError, 'reviver-get-name-err'); } - assert.throws(() => parse('0', () => { throw EvalError('t262'); }), EvalError, 'reviver-call-err'); + assert.throws(() => parse('0', () => { throw new EvalError('t262'); }), EvalError, 'reviver-call-err'); // FF20- enumeration order issue if (keys({ k: 1, 2: 3 })[0] === '2') { diff --git a/tests/unit-pure/web.url.can-parse.js b/tests/unit-pure/web.url.can-parse.js index b64c111c6486..9e1ab1eba425 100644 --- a/tests/unit-pure/web.url.can-parse.js +++ b/tests/unit-pure/web.url.can-parse.js @@ -19,6 +19,6 @@ QUnit.test('URL.canParse', assert => { assert.true(canParse('x', 'https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'), 'x, https://login:password@example.com:8080/?a=1&b=2&a=3&c=4#fragment'); assert.throws(() => canParse(), 'no args'); - assert.throws(() => canParse({ toString() { throw Error('thrower'); } }), 'conversion thrower #1'); - assert.throws(() => canParse('q:w', { toString() { throw Error('thrower'); } }), 'conversion thrower #2'); + assert.throws(() => canParse({ toString() { throw new Error('thrower'); } }), 'conversion thrower #1'); + assert.throws(() => canParse('q:w', { toString() { throw new Error('thrower'); } }), 'conversion thrower #2'); });