diff --git a/lib/chai/assertion.js b/lib/chai/assertion.js index 54a9d77f..4d5e2097 100644 --- a/lib/chai/assertion.js +++ b/lib/chai/assertion.js @@ -9,7 +9,7 @@ import {config} from './config.js'; import {AssertionError} from 'assertion-error'; import * as util from './utils/index.js'; -/*! +/** * Assertion Constructor * * Creates object for chaining. @@ -42,10 +42,10 @@ import * as util from './utils/index.js'; * * - `eql`: This flag contains the deepEqual function to be used by the assertion. * - * @param {Mixed} obj target of the assertion - * @param {String} msg (optional) custom error message - * @param {Function} ssfi (optional) starting point for removing stack frames - * @param {Boolean} lockSsfi (optional) whether or not the ssfi flag is locked + * @param {unknown} obj target of the assertion + * @param {String} [msg] custom error message + * @param {Function} [ssfi] starting point for removing stack frames + * @param {Boolean} [lockSsfi] whether or not the ssfi flag is locked * @api private */ @@ -81,26 +81,52 @@ Object.defineProperty(Assertion, 'showDiff', { } }); +/** + * @param {string} name + * @param {Function} fn + */ Assertion.addProperty = function (name, fn) { util.addProperty(this.prototype, name, fn); }; +/** + * @param {string} name + * @param {Function} fn + */ Assertion.addMethod = function (name, fn) { util.addMethod(this.prototype, name, fn); }; +/** + * @param {string} name + * @param {Function} fn + * @param {Function} chainingBehavior + */ Assertion.addChainableMethod = function (name, fn, chainingBehavior) { util.addChainableMethod(this.prototype, name, fn, chainingBehavior); }; +/** + * @param {string} name + * @param {Function} fn + */ Assertion.overwriteProperty = function (name, fn) { util.overwriteProperty(this.prototype, name, fn); }; +/** + * @param {string} name + * @param {Function} fn + */ Assertion.overwriteMethod = function (name, fn) { util.overwriteMethod(this.prototype, name, fn); }; +/** + * @param {string} name + * @param {Function} fn + * @param {Function} chainingBehavior + */ Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) { util.overwriteChainableMethod(this.prototype, name, fn, chainingBehavior); }; @@ -111,12 +137,12 @@ Assertion.overwriteChainableMethod = function (name, fn, chainingBehavior) { * Executes an expression and check expectations. Throws AssertionError for reporting if test doesn't pass. * * @name assert - * @param {Philosophical} expression to be tested - * @param {String|Function} message or function that returns message to display if expression fails - * @param {String|Function} negatedMessage or function that returns negatedMessage to display if negated expression fails - * @param {Mixed} expected value (remember to check for negation) - * @param {Mixed} actual (optional) will default to `this.obj` - * @param {Boolean} showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails + * @param {unknown} expr expression to be tested + * @param {String|Function} msg message or function that returns message to display if expression fails + * @param {String|Function} negateMsg negatedMessage or function that returns negatedMessage to display if negated expression fails + * @param {unknown} [expected] value (remember to check for negation) + * @param {unknown} [_actual] will default to `this.obj` + * @param {Boolean} [showDiff] when set to `true`, assert will display a diff in addition to the message if expression fails * @api private */ @@ -127,12 +153,13 @@ Assertion.prototype.assert = function (expr, msg, negateMsg, expected, _actual, if (true !== config.showDiff) showDiff = false; if (!ok) { - msg = util.getMessage(this, arguments); + msg = util.getMessage(this, msg, negateMsg, expected, _actual); var actual = util.getActual(this, arguments); var assertionErrorObjectProperties = { actual: actual , expected: expected , showDiff: showDiff + , operator: undefined }; var operator = util.getOperator(this, arguments); diff --git a/lib/chai/interface/assert.js b/lib/chai/interface/assert.js index 77af8ead..143f1035 100644 --- a/lib/chai/interface/assert.js +++ b/lib/chai/interface/assert.js @@ -17,15 +17,15 @@ import {AssertionError} from 'assertion-error'; * assert('foo' !== 'bar', 'foo is not bar'); * assert(Array.isArray([]), 'empty arrays are arrays'); * - * @param {Mixed} expression to test for truthiness - * @param {String} message to display on error + * @param {unknown} express expression to test for truthiness + * @param {String} errmsg message to display on error * @name assert * @namespace Assert * @api public */ function assert(express, errmsg) { - var test = new Assertion(null, null, chai.assert, true); + var test = new Assertion(undefined, undefined, chai.assert, true); test.assert( express , errmsg @@ -49,10 +49,10 @@ export {assert}; * assert.fail(1, 2, undefined, ">"); * * @name fail - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message - * @param {String} operator + * @param {string | undefined} actual + * @param {string | undefined} expected + * @param {String} [message] + * @param {String} [operator] * @namespace Assert * @api public */ @@ -83,8 +83,8 @@ assert.fail = function (actual, expected, message, operator) { * * @name isOk * @alias ok - * @param {Mixed} object to test - * @param {String} message + * @param {unknown} val object to test + * @param {String} msg * @namespace Assert * @api public */ @@ -103,8 +103,8 @@ assert.isOk = function (val, msg) { * * @name isNotOk * @alias notOk - * @param {Mixed} object to test - * @param {String} message + * @param {unknown} val object to test + * @param {String} msg message * @namespace Assert * @api public */ @@ -121,9 +121,9 @@ assert.isNotOk = function (val, msg) { * assert.equal(3, '3', '== coerces values to strings'); * * @name equal - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message + * @param {unknown} act + * @param {unknown} exp + * @param {String} msg * @namespace Assert * @api public */ @@ -149,9 +149,9 @@ assert.equal = function (act, exp, msg) { * assert.notEqual(3, 4, 'these numbers are not equal'); * * @name notEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message + * @param {unknown} act + * @param {unknown} exp + * @param {String} msg * @namespace Assert * @api public */ @@ -177,9 +177,9 @@ assert.notEqual = function (act, exp, msg) { * assert.strictEqual(true, true, 'these booleans are strictly equal'); * * @name strictEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message + * @param {unknown} act + * @param {unknown} exp + * @param {String} msg * @namespace Assert * @api public */ @@ -196,9 +196,9 @@ assert.strictEqual = function (act, exp, msg) { * assert.notStrictEqual(3, '3', 'no coercion for strict equality'); * * @name notStrictEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message + * @param {unknown} act + * @param {unknown} exp + * @param {String} msg * @namespace Assert * @api public */ @@ -215,9 +215,9 @@ assert.notStrictEqual = function (act, exp, msg) { * assert.deepEqual({ tea: 'green' }, { tea: 'green' }); * * @name deepEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message + * @param {unknown} act + * @param {unknown} exp + * @param {String} msg * @alias deepStrictEqual * @namespace Assert * @api public @@ -235,9 +235,9 @@ assert.deepEqual = assert.deepStrictEqual = function (act, exp, msg) { * assert.notDeepEqual({ tea: 'green' }, { tea: 'jasmine' }); * * @name notDeepEqual - * @param {Mixed} actual - * @param {Mixed} expected - * @param {String} message + * @param {unknown} act + * @param {unknown} exp + * @param {String} msg * @namespace Assert * @api public */ @@ -254,15 +254,15 @@ assert.notDeepEqual = function (act, exp, msg) { * assert.isAbove(5, 2, '5 is strictly greater than 2'); * * @name isAbove - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAbove + * @param {unknown} valueToCheck + * @param {unknown} valueToBeAbove * @param {String} message * @namespace Assert * @api public */ -assert.isAbove = function (val, abv, msg) { - new Assertion(val, msg, assert.isAbove, true).to.be.above(abv); +assert.isAbove = function (valueToCheck, valueToBeAbove, message) { + new Assertion(valueToCheck, message, assert.isAbove, true).to.be.above(valueToBeAbove); }; /** @@ -274,15 +274,15 @@ assert.isAbove = function (val, abv, msg) { * assert.isAtLeast(3, 3, '3 is greater or equal to 3'); * * @name isAtLeast - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAtLeast + * @param {unknown} valueToCheck + * @param {unknown} valueToBeAtLeast * @param {String} message * @namespace Assert * @api public */ -assert.isAtLeast = function (val, atlst, msg) { - new Assertion(val, msg, assert.isAtLeast, true).to.be.least(atlst); +assert.isAtLeast = function (valueToCheck, valueToBeAtLeast, message) { + new Assertion(valueToCheck, message, assert.isAtLeast, true).to.be.least(valueToBeAtLeast); }; /** @@ -293,8 +293,8 @@ assert.isAtLeast = function (val, atlst, msg) { * assert.isBelow(3, 6, '3 is strictly less than 6'); * * @name isBelow - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeBelow + * @param {unknown} valueToCheck + * @param {unknown} valueToBeBelow * @param {String} message * @namespace Assert * @api public @@ -313,8 +313,8 @@ assert.isBelow = function (val, blw, msg) { * assert.isAtMost(4, 4, '4 is less than or equal to 4'); * * @name isAtMost - * @param {Mixed} valueToCheck - * @param {Mixed} valueToBeAtMost + * @param {unknown} valueToCheck + * @param {unknown} valueToBeAtMost * @param {String} message * @namespace Assert * @api public @@ -333,7 +333,7 @@ assert.isAtMost = function (val, atmst, msg) { * assert.isTrue(teaServed, 'the tea has been served'); * * @name isTrue - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -352,7 +352,7 @@ assert.isTrue = function (val, msg) { * assert.isNotTrue(tea, 'great, time for tea!'); * * @name isNotTrue - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -371,7 +371,7 @@ assert.isNotTrue = function (val, msg) { * assert.isFalse(teaServed, 'no tea yet? hmm...'); * * @name isFalse - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -390,7 +390,7 @@ assert.isFalse = function (val, msg) { * assert.isNotFalse(tea, 'great, time for tea!'); * * @name isNotFalse - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -408,7 +408,7 @@ assert.isNotFalse = function (val, msg) { * assert.isNull(err, 'there was no error'); * * @name isNull - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -427,7 +427,7 @@ assert.isNull = function (val, msg) { * assert.isNotNull(tea, 'great, time for tea!'); * * @name isNotNull - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -445,7 +445,7 @@ assert.isNotNull = function (val, msg) { * assert.isNaN(NaN, 'NaN is NaN'); * * @name isNaN - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -463,7 +463,7 @@ assert.isNaN = function (val, msg) { * assert.isNotNaN(4, '4 is not NaN'); * * @name isNotNaN - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -482,7 +482,7 @@ assert.isNotNaN = function (val, msg) { * assert.exists(foo, 'foo is neither `null` nor `undefined`'); * * @name exists - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -504,7 +504,7 @@ assert.exists = function (val, msg) { * assert.notExists(baz, 'baz is either null or undefined'); * * @name notExists - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -523,7 +523,7 @@ assert.notExists = function (val, msg) { * assert.isUndefined(tea, 'no tea defined'); * * @name isUndefined - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -542,7 +542,7 @@ assert.isUndefined = function (val, msg) { * assert.isDefined(tea, 'tea has been defined'); * * @name isDefined - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -561,7 +561,7 @@ assert.isDefined = function (val, msg) { * assert.isFunction(serveTea, 'great, we can have tea now'); * * @name isFunction - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -580,7 +580,7 @@ assert.isFunction = function (val, msg) { * assert.isNotFunction(serveTea, 'great, we have listed the steps'); * * @name isNotFunction - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -600,7 +600,7 @@ assert.isNotFunction = function (val, msg) { * assert.isObject(selection, 'tea selection is an object'); * * @name isObject - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -620,7 +620,7 @@ assert.isObject = function (val, msg) { * assert.isNotObject(null, 'null is not an object'); * * @name isNotObject - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -639,7 +639,7 @@ assert.isNotObject = function (val, msg) { * assert.isArray(menu, 'what kind of tea do we want?'); * * @name isArray - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -658,7 +658,7 @@ assert.isArray = function (val, msg) { * assert.isNotArray(menu, 'what kind of tea do we want?'); * * @name isNotArray - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -677,7 +677,7 @@ assert.isNotArray = function (val, msg) { * assert.isString(teaOrder, 'order placed'); * * @name isString - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -696,7 +696,7 @@ assert.isString = function (val, msg) { * assert.isNotString(teaOrder, 'order placed'); * * @name isNotString - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -734,7 +734,7 @@ assert.isNumber = function (val, msg) { * assert.isNotNumber(cups, 'how many cups'); * * @name isNotNumber - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -777,7 +777,7 @@ assert.isFinite = function (val, msg) { * assert.isBoolean(teaServed, 'has tea been served'); * * @name isBoolean - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -799,7 +799,7 @@ assert.isBoolean = function (val, msg) { * assert.isNotBoolean(teaServed, 'has tea been served'); * * @name isNotBoolean - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -823,7 +823,7 @@ assert.isNotBoolean = function (val, msg) { * assert.typeOf(undefined, 'undefined', 'we have an undefined'); * * @name typeOf - * @param {Mixed} value + * @param {unknown} value * @param {String} name * @param {String} message * @namespace Assert @@ -843,7 +843,7 @@ assert.typeOf = function (val, type, msg) { * assert.notTypeOf('tea', 'number', 'strings are not numbers'); * * @name notTypeOf - * @param {Mixed} value + * @param {unknown} value * @param {String} typeof name * @param {String} message * @namespace Assert @@ -924,7 +924,7 @@ assert.notInstanceOf = function (val, type, msg) { * * @name include * @param {Array|String} haystack - * @param {Mixed} needle + * @param {unknown} needle * @param {String} message * @namespace Assert * @api public @@ -960,7 +960,7 @@ assert.include = function (exp, inc, msg) { * * @name notInclude * @param {Array|String} haystack - * @param {Mixed} needle + * @param {unknown} needle * @param {String} message * @namespace Assert * @api public @@ -985,7 +985,7 @@ assert.notInclude = function (exp, inc, msg) { * * @name deepInclude * @param {Array|String} haystack - * @param {Mixed} needle + * @param {unknown} needle * @param {String} message * @namespace Assert * @api public @@ -1010,7 +1010,7 @@ assert.deepInclude = function (exp, inc, msg) { * * @name notDeepInclude * @param {Array|String} haystack - * @param {Mixed} needle + * @param {unknown} needle * @param {String} message * @namespace Assert * @api public @@ -1219,7 +1219,7 @@ assert.notDeepOwnInclude = function(exp, inc, msg) { * assert.match('foobar', /^foo/, 'regexp matches'); * * @name match - * @param {Mixed} value + * @param {unknown} value * @param {RegExp} regexp * @param {String} message * @namespace Assert @@ -1238,7 +1238,7 @@ assert.match = function (exp, re, msg) { * assert.notMatch('foobar', /^foo/, 'regexp does not match'); * * @name notMatch - * @param {Mixed} value + * @param {unknown} value * @param {RegExp} regexp * @param {String} message * @namespace Assert @@ -1303,7 +1303,7 @@ assert.notProperty = function (obj, prop, msg) { * @name propertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -1327,7 +1327,7 @@ assert.propertyVal = function (obj, prop, val, msg) { * @name notPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -1349,7 +1349,7 @@ assert.notPropertyVal = function (obj, prop, val, msg) { * @name deepPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -1373,7 +1373,7 @@ assert.deepPropertyVal = function (obj, prop, val, msg) { * @name notDeepPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -1437,7 +1437,7 @@ assert.notOwnProperty = function (obj, prop, msg) { * @name ownPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @api public */ @@ -1460,7 +1460,7 @@ assert.ownPropertyVal = function (obj, prop, value, msg) { * @name notOwnPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @api public */ @@ -1482,7 +1482,7 @@ assert.notOwnPropertyVal = function (obj, prop, value, msg) { * @name deepOwnPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @api public */ @@ -1507,7 +1507,7 @@ assert.deepOwnPropertyVal = function (obj, prop, value, msg) { * @name notDeepOwnPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @api public */ @@ -1573,7 +1573,7 @@ assert.notNestedProperty = function (obj, prop, msg) { * @name nestedPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -1597,7 +1597,7 @@ assert.nestedPropertyVal = function (obj, prop, val, msg) { * @name notNestedPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -1620,7 +1620,7 @@ assert.notNestedPropertyVal = function (obj, prop, val, msg) { * @name deepNestedPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -1645,7 +1645,7 @@ assert.deepNestedPropertyVal = function (obj, prop, val, msg) { * @name notDeepNestedPropertyVal * @param {Object} object * @param {String} property - * @param {Mixed} value + * @param {unknown} value * @param {String} message * @namespace Assert * @api public @@ -1667,7 +1667,7 @@ assert.notDeepNestedPropertyVal = function (obj, prop, val, msg) { * assert.lengthOf(new Map([['a',1],['b',2],['c',3]]), 3, 'map has size of 3'); * * @name lengthOf - * @param {Mixed} object + * @param {unknown} object * @param {Number} length * @param {String} message * @namespace Assert @@ -1691,7 +1691,7 @@ assert.lengthOf = function (exp, len, msg) { * assert.hasAnyKeys(new Set([{foo: 'bar'}, 'anotherKey']), [{foo: 'bar'}, 'anotherKey']); * * @name hasAnyKeys - * @param {Mixed} object + * @param {unknown} object * @param {Array|Object} keys * @param {String} message * @namespace Assert @@ -1715,7 +1715,7 @@ assert.hasAnyKeys = function (obj, keys, msg) { * assert.hasAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}, 'anotherKey']); * * @name hasAllKeys - * @param {Mixed} object + * @param {unknown} object * @param {String[]} keys * @param {String} message * @namespace Assert @@ -1743,7 +1743,7 @@ assert.hasAllKeys = function (obj, keys, msg) { * assert.containsAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{foo: 'bar'}, 'anotherKey']); * * @name containsAllKeys - * @param {Mixed} object + * @param {unknown} object * @param {String[]} keys * @param {String} message * @namespace Assert @@ -1768,7 +1768,7 @@ assert.containsAllKeys = function (obj, keys, msg) { * assert.doesNotHaveAnyKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{one: 'two'}, 'example']); * * @name doesNotHaveAnyKeys - * @param {Mixed} object + * @param {unknown} object * @param {String[]} keys * @param {String} message * @namespace Assert @@ -1793,7 +1793,7 @@ assert.doesNotHaveAnyKeys = function (obj, keys, msg) { * assert.doesNotHaveAllKeys(new Set([{foo: 'bar'}, 'anotherKey'], [{one: 'two'}, 'example']); * * @name doesNotHaveAllKeys - * @param {Mixed} object + * @param {unknown} object * @param {String[]} keys * @param {String} message * @namespace Assert @@ -1822,7 +1822,7 @@ assert.doesNotHaveAllKeys = function (obj, keys, msg) { * assert.hasAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); * * @name hasAnyDeepKeys - * @param {Mixed} object + * @param {unknown} object * @param {Array|Object} keys * @param {String} message * @namespace Assert @@ -1849,7 +1849,7 @@ assert.hasAnyDeepKeys = function (obj, keys, msg) { * assert.hasAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); * * @name hasAllDeepKeys - * @param {Mixed} object + * @param {unknown} object * @param {Array|Object} keys * @param {String} message * @namespace Assert @@ -1876,7 +1876,7 @@ assert.hasAllDeepKeys = function (obj, keys, msg) { * assert.containsAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {two: 'two'}]); * * @name containsAllDeepKeys - * @param {Mixed} object + * @param {unknown} object * @param {Array|Object} keys * @param {String} message * @namespace Assert @@ -1903,7 +1903,7 @@ assert.containsAllDeepKeys = function (obj, keys, msg) { * assert.doesNotHaveAnyDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{twenty: 'twenty'}, {fifty: 'fifty'}]); * * @name doesNotHaveAnyDeepKeys - * @param {Mixed} object + * @param {unknown} object * @param {Array|Object} keys * @param {String} message * @namespace Assert @@ -1930,7 +1930,7 @@ assert.doesNotHaveAnyDeepKeys = function (obj, keys, msg) { * assert.doesNotHaveAllDeepKeys(new Set([{one: 'one'}, {two: 'two'}]), [{one: 'one'}, {fifty: 'fifty'}]); * * @name doesNotHaveAllDeepKeys - * @param {Mixed} object + * @param {unknown} object * @param {Array|Object} keys * @param {String} message * @namespace Assert @@ -2032,9 +2032,9 @@ assert.doesNotThrow = function (fn, errorLike, errMsgMatcher, msg) { * assert.operator(1, '>', 2, 'this will fail'); * * @name operator - * @param {Mixed} val1 + * @param {unknown} val1 * @param {String} operator - * @param {Mixed} val2 + * @param {unknown} val2 * @param {String} message * @namespace Assert * @api public diff --git a/lib/chai/utils/flag.js b/lib/chai/utils/flag.js index 79637ad3..38ba03c6 100644 --- a/lib/chai/utils/flag.js +++ b/lib/chai/utils/flag.js @@ -15,14 +15,13 @@ * utils.flag(this, 'foo', 'bar'); // setter * utils.flag(this, 'foo'); // getter, returns `bar` * - * @param {Object} object constructed Assertion + * @param {Object & {__flags?: unknown}} obj object constructed Assertion * @param {String} key - * @param {Mixed} value (optional) + * @param {unknown} [value] * @namespace Utils * @name flag * @api private */ - export function flag(obj, key, value) { var flags = obj.__flags || (obj.__flags = Object.create(null)); if (arguments.length === 3) { diff --git a/lib/chai/utils/getMessage.js b/lib/chai/utils/getMessage.js index 97c4826e..24e8de42 100644 --- a/lib/chai/utils/getMessage.js +++ b/lib/chai/utils/getMessage.js @@ -1,4 +1,4 @@ -/*! +/* * Chai - message composition utility * Copyright(c) 2012-2014 Jake Luer * MIT Licensed @@ -24,27 +24,32 @@ import {objDisplay} from './objDisplay.js'; * - `#{act}` actual value * - `#{exp}` expected value * - * @param {Object} object (constructed Assertion) - * @param {Arguments} chai.Assertion.prototype.assert arguments + * @param {object} obj object (constructed Assertion) + * @param {String|Function} msg message or function that returns message to display if expression fails + * @param {String|Function} negateMsg negatedMessage or function that returns negatedMessage to display if negated expression fails + * @param {unknown} expected value (remember to check for negation) + * @param {unknown} [_actual] will default to `this.obj` + * @returns {string} * @namespace Utils * @name getMessage * @api public */ -export function getMessage(obj, args) { +export function getMessage(obj, msg, negateMsg, expected, _actual) { var negate = flag(obj, 'negate') , val = flag(obj, 'object') - , expected = args[3] - , actual = getActual(obj, args) - , msg = negate ? args[2] : args[1] + , actual = getActual(obj, arguments) + , msg = negate ? negateMsg : msg , flagMsg = flag(obj, 'message'); if(typeof msg === "function") msg = msg(); msg = msg || ''; msg = msg + // @ts-ignore `msg` is a string at this point. Probably there's a way to tell TypeScript that. .replace(/#\{this\}/g, function () { return objDisplay(val); }) .replace(/#\{act\}/g, function () { return objDisplay(actual); }) .replace(/#\{exp\}/g, function () { return objDisplay(expected); }); + // @ts-ignore `msg` is a string at this point. Probably there's a way to tell TypeScript that. return flagMsg ? flagMsg + ': ' + msg : msg; } diff --git a/lib/chai/utils/index.js b/lib/chai/utils/index.js index 4b9eba8b..3b1ef4e1 100644 --- a/lib/chai/utils/index.js +++ b/lib/chai/utils/index.js @@ -75,8 +75,10 @@ export {default as eql} from 'deep-eql'; export {getPathInfo, hasProperty} from 'pathval'; -/*! +/** * Function name + * + * @param {Function} fn */ export function getName(fn) { diff --git a/lib/chai/utils/proxify.js b/lib/chai/utils/proxify.js index ca1a2c2b..34dd8d8f 100644 --- a/lib/chai/utils/proxify.js +++ b/lib/chai/utils/proxify.js @@ -9,6 +9,8 @@ import {isProxyEnabled} from './isProxyEnabled.js'; * MIT Licensed */ +const builtins = ['__flags', '__methods', '_obj', 'assert']; + /** * ### .proxify(object) * @@ -23,14 +25,11 @@ import {isProxyEnabled} from './isProxyEnabled.js'; * return object without modification. * * @param {Object} obj - * @param {String} nonChainableMethodName + * @param {String} [nonChainableMethodName] * @namespace Utils * @name proxify */ - -const builtins = ['__flags', '__methods', '_obj', 'assert']; - -export function proxify(obj ,nonChainableMethodName) { +export function proxify(obj, nonChainableMethodName) { if (!isProxyEnabled()) return obj; return new Proxy(obj, { @@ -105,7 +104,7 @@ export function proxify(obj ,nonChainableMethodName) { * Return the Levenshtein distance between two strings, but no more than cap. * @param {string} strA * @param {string} strB - * @param {number} number + * @param {number} cap * @return {number} min(string distance between strA and strB, cap) * @api private */ diff --git a/package-lock.json b/package-lock.json index 8e697ec8..d9544ed3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,8 @@ "@web/test-runner-playwright": "^0.10.2", "bump-cli": "^1.1.3", "esbuild": "^0.17.3", - "mocha": "^8.3.0" + "mocha": "^8.3.0", + "typescript": "^5.3.3" }, "engines": { "node": ">=12" @@ -482,15 +483,6 @@ } } }, - "node_modules/@tootallnate/once": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", - "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", - "dev": true, - "engines": { - "node": ">= 6" - } - }, "node_modules/@tootallnate/quickjs-emscripten": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", @@ -1297,12 +1289,6 @@ "node": ">=16.0.0" } }, - "node_modules/abbrev": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", - "integrity": "sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q==", - "dev": true - }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -1316,51 +1302,6 @@ "node": ">= 0.6" } }, - "node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dev": true, - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/agent-base/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/agent-base/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "node_modules/amdefine": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", - "integrity": "sha512-S2Hw0TtNkMJhIabBwIojKL9YHO5T0n5eNqWJ7Lrlel/zDbftQpxpapi8tZs3X1HWa+u+QeydGmzzNU0m09+Rcg==", - "dev": true, - "optional": true, - "engines": { - "node": ">=0.4.2" - } - }, "node_modules/ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", @@ -1434,24 +1375,6 @@ "node": ">= 8" } }, - "node_modules/argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "dependencies": { - "sprintf-js": "~1.0.2" - } - }, - "node_modules/argv": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/argv/-/argv-0.0.2.tgz", - "integrity": "sha512-dEamhpPEwRUBpLNHeuCm/v+g0anFByHahxodVO/BbAarHVBBg2MccCwf9K+o1Pof+2btdnkJelYVUWjW/VrATw==", - "dev": true, - "engines": { - "node": ">=0.6.10" - } - }, "node_modules/array-back": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz", @@ -1499,12 +1422,6 @@ "node": ">=8" } }, - "node_modules/async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha512-nSVgobk4rv61R9PUSDtYt7mPVB2olxNR5RWJcAsH676/ef11bUZwvu7+RGYrYauVdDPcO519v68wRhXQtxsV9w==", - "dev": true - }, "node_modules/async-mutex": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.4.0.tgz", @@ -1859,26 +1776,6 @@ "type-is": "^1.6.16" } }, - "node_modules/codecov": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.8.3.tgz", - "integrity": "sha512-Y8Hw+V3HgR7V71xWH2vQ9lyS358CbGCldWlJFR0JirqoGtOoas3R3/OclRTvgUYFK29mmJICDPauVKmpqbwhOA==", - "deprecated": "https://about.codecov.io/blog/codecov-uploader-deprecation-plan/", - "dev": true, - "dependencies": { - "argv": "0.0.2", - "ignore-walk": "3.0.4", - "js-yaml": "3.14.1", - "teeny-request": "7.1.1", - "urlgrey": "1.0.0" - }, - "bin": { - "codecov": "bin/codecov" - }, - "engines": { - "node": ">=4.0" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2047,12 +1944,6 @@ "integrity": "sha512-bHtC0iYvWhyaTzvV3CZgPeZQqCOBGyGsVV7v4eevpdkLHfiSrXUdBG+qAuSz4RI70sszvjQ1QSZ98An1yNwpSw==", "dev": true }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "dev": true - }, "node_modules/deepmerge": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", @@ -2306,63 +2197,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/escodegen": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", - "integrity": "sha512-yhi5S+mNTOuRvyW4gWlg5W1byMaQGWWSYHXsuFZ7GBo7tpyOwi2EdzMP/QWxh9hwkD2m+wDVHJsxhRIj+v/b/A==", - "dev": true, - "dependencies": { - "esprima": "^2.7.1", - "estraverse": "^1.9.1", - "esutils": "^2.0.2", - "optionator": "^0.8.1" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=0.12.0" - }, - "optionalDependencies": { - "source-map": "~0.2.0" - } - }, - "node_modules/escodegen/node_modules/source-map": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", - "integrity": "sha512-CBdZ2oa/BHhS4xj5DlhjWNHcan57/5YuvfdLf17iVmIpd9KRm+DFLmC6nBNj+6Ua7Kt3TmOjDpQT1aTYOQtoUA==", - "dev": true, - "optional": true, - "dependencies": { - "amdefine": ">=0.0.4" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/esprima": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", - "integrity": "sha512-OarPfz0lFCiW4/AV2Oy1Rp9qu0iusTKqykwTspGCZtPxmF81JR4MmIebvF1F9+UOKth2ZubLQ4XGGaU+hSn99A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/estraverse": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", - "integrity": "sha512-25w1fMXQrGdoquWnScXZGckOv+Wes+JDnuN/+7ex3SauFRS72r2lFDec0EKPt2YD1wUJ/IrfEex+9yp4hfSOJA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/estree-walker": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", @@ -2467,21 +2301,6 @@ "node": ">=8.6.0" } }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "dev": true - }, - "node_modules/fast-url-parser": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/fast-url-parser/-/fast-url-parser-1.1.3.tgz", - "integrity": "sha512-5jOCVXADYNuRkKFzNJ0dCCewsZiYo0dz8QNYljkOpFC6r2U4OBmKtvm/Tsuh4w1YYdDqDb31a8TVhBJ2OJKdqQ==", - "dev": true, - "dependencies": { - "punycode": "^1.3.2" - } - }, "node_modules/fastq": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", @@ -2714,36 +2533,6 @@ "node": ">=4.x" } }, - "node_modules/handlebars": { - "version": "4.7.7", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.7.tgz", - "integrity": "sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==", - "dev": true, - "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.0", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" - }, - "engines": { - "node": ">=0.4.7" - }, - "optionalDependencies": { - "uglify-js": "^3.1.4" - } - }, - "node_modules/handlebars/node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -2756,15 +2545,6 @@ "node": ">= 0.4.0" } }, - "node_modules/has-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha512-DyYHfIYwAJmjAjSSPKANxI8bFY9YtFrgkAfinBojQ8YJTOuOuav64tMUJv584SES4xl74PmuaevIyaLESHdTAA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", @@ -2870,79 +2650,6 @@ "node": ">= 0.8" } }, - "node_modules/http-proxy-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", - "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", - "dev": true, - "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/http-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/http-proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dev": true, - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/https-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "dev": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/https-proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -2984,15 +2691,6 @@ "node": ">= 4" } }, - "node_modules/ignore-walk": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.4.tgz", - "integrity": "sha512-PY6Ii8o1jMRA1z4F2hRkH/xN59ox43DavKvD3oDpfurRlOJyAHpifIwpbdv1n4jt4ov0jSpw3kQ4GhJnpBL6WQ==", - "dev": true, - "dependencies": { - "minimatch": "^3.0.4" - } - }, "node_modules/inflation": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/inflation/-/inflation-2.1.0.tgz", @@ -3165,32 +2863,6 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, - "node_modules/istanbul": { - "version": "0.4.5", - "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", - "integrity": "sha512-nMtdn4hvK0HjUlzr1DrKSUY8ychprt8dzHOgY2KXsIhHu5PuQQEOTM27gV9Xblyon7aUH/TSFIjRHEODF/FRPg==", - "deprecated": "This module is no longer maintained, try this instead:\n npm i nyc\nVisit https://istanbul.js.org/integrations for other alternatives.", - "dev": true, - "dependencies": { - "abbrev": "1.0.x", - "async": "1.x", - "escodegen": "1.8.x", - "esprima": "2.7.x", - "glob": "^5.0.15", - "handlebars": "^4.0.1", - "js-yaml": "3.x", - "mkdirp": "0.5.x", - "nopt": "3.x", - "once": "1.x", - "resolve": "1.1.x", - "supports-color": "^3.1.0", - "which": "^1.1.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "istanbul": "lib/cli.js" - } - }, "node_modules/istanbul-lib-coverage": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", @@ -3296,60 +2968,12 @@ "node": ">=8" } }, - "node_modules/istanbul/node_modules/glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha512-c9IPMazfRITpmAAKi22dK1VKxGDX9ehhqfABDriL/lzO92xcUKEJPQHrVA/2YHSNFB4iFlykVmWvwo48nr3OxA==", - "dev": true, - "dependencies": { - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "2 || 3", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - } - }, - "node_modules/istanbul/node_modules/resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha512-9znBF0vBcaSN3W2j7wKvdERPwqTxSpCq+if5C0WoTCyV9n24rua28jeuQ2pL/HOf+yUe/Mef+H/5p60K0Id3bg==", - "dev": true - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, - "node_modules/js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", - "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", - "dev": true, - "dependencies": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - }, - "bin": { - "js-yaml": "bin/js-yaml.js" - } - }, - "node_modules/js-yaml/node_modules/esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true, - "bin": { - "esparse": "bin/esparse.js", - "esvalidate": "bin/esvalidate.js" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -3571,19 +3195,6 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, - "node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "dev": true, - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/lighthouse-logger": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/lighthouse-logger/-/lighthouse-logger-1.3.0.tgz", @@ -3782,18 +3393,6 @@ "node": ">=6" } }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, "node_modules/minimist": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.7.tgz", @@ -4055,12 +3654,6 @@ "node": ">= 0.6" } }, - "node_modules/neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true - }, "node_modules/netmask": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", @@ -4090,18 +3683,6 @@ } } }, - "node_modules/nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha512-4GUt3kSEYmk4ITxzB/b9vaIDfUVWN/Ml1Fwl11IlnIG2iaJ9O6WXZ9SrYM9NLI8OCBieN2Y8SWC2oJV0RQ7qYg==", - "dev": true, - "dependencies": { - "abbrev": "1" - }, - "bin": { - "nopt": "bin/nopt.js" - } - }, "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", @@ -4179,23 +3760,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -4462,15 +4026,6 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "dev": true, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -4585,12 +4140,6 @@ "once": "^1.3.1" } }, - "node_modules/punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", - "dev": true - }, "node_modules/qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", @@ -4998,12 +4547,6 @@ "node": ">= 8" } }, - "node_modules/sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", - "dev": true - }, "node_modules/statuses": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", @@ -5013,15 +4556,6 @@ "node": ">= 0.6" } }, - "node_modules/stream-events": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/stream-events/-/stream-events-1.0.5.tgz", - "integrity": "sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg==", - "dev": true, - "dependencies": { - "stubs": "^3.0.0" - } - }, "node_modules/stream-read-all": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/stream-read-all/-/stream-read-all-3.0.1.tgz", @@ -5099,24 +4633,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/stubs": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/stubs/-/stubs-3.0.0.tgz", - "integrity": "sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw==", - "dev": true - }, - "node_modules/supports-color": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha512-Jds2VIYDrlp5ui7t8abHN2bjAu4LV/q4N2KivFPpGH0lrka0BMq/33AmECUXlKPcHigkNaqfXRENFju+rlcy+A==", - "dev": true, - "dependencies": { - "has-flag": "^1.0.0" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", @@ -5168,22 +4684,6 @@ "node": ">=12.17" } }, - "node_modules/teeny-request": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-7.1.1.tgz", - "integrity": "sha512-iwY6rkW5DDGq8hE2YgNQlKbptYpY5Nn2xecjQiNjOXWbKzPGUfmeUBCSQbbr306d7Z7U2N0TPl+/SwYRfua1Dg==", - "dev": true, - "dependencies": { - "http-proxy-agent": "^4.0.0", - "https-proxy-agent": "^5.0.0", - "node-fetch": "^2.6.1", - "stream-events": "^1.0.5", - "uuid": "^8.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -5232,18 +4732,6 @@ "node": ">=0.6.x" } }, - "node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "dev": true, - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -5257,6 +4745,19 @@ "node": ">= 0.6" } }, + "node_modules/typescript": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/typical": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz", @@ -5266,19 +4767,6 @@ "node": ">=8" } }, - "node_modules/uglify-js": { - "version": "3.17.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", - "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", - "dev": true, - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/unbzip2-stream": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", @@ -5307,24 +4795,6 @@ "node": ">= 0.8" } }, - "node_modules/urlgrey": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/urlgrey/-/urlgrey-1.0.0.tgz", - "integrity": "sha512-hJfIzMPJmI9IlLkby8QrsCykQ+SXDeO2W5Q9QTW3QpqZVTx4a/K7p8/5q+/isD8vsbVaFgql/gvAoQCRQ2Cb5w==", - "dev": true, - "dependencies": { - "fast-url-parser": "^1.1.3" - } - }, - "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "dev": true, - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/v8-to-istanbul": { "version": "9.1.3", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.3.tgz", @@ -5364,18 +4834,6 @@ "webidl-conversions": "^3.0.0" } }, - "node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "which": "bin/which" - } - }, "node_modules/wide-align": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", @@ -5385,21 +4843,6 @@ "string-width": "^1.0.2 || 2" } }, - "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", - "dev": true - }, "node_modules/wordwrapjs": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-5.1.0.tgz", diff --git a/package.json b/package.json index d51321bd..b745594a 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,9 @@ "main": "./chai.js", "scripts": { "prebuild": "npm run clean", - "build": "npm run build:esm", + "build": "npm run build:esm && npm run build:types", "build:esm": "esbuild --bundle --format=esm --keep-names --outfile=chai.js index.js", + "build:types": "tsc", "pretest": "npm run build", "test": "npm run test-node && npm run test-chrome", "test-node": "mocha --require ./test/bootstrap/index.js --reporter dot test/*.js", @@ -54,6 +55,7 @@ "@web/test-runner-playwright": "^0.10.2", "bump-cli": "^1.1.3", "esbuild": "^0.17.3", - "mocha": "^8.3.0" + "mocha": "^8.3.0", + "typescript": "~5.3.3" } } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..3636750b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "ES2018", + "strict": true, + "moduleResolution": "node", + "declaration": true, + "emitDeclarationOnly": true, + "checkJs": true, + "outDir": "types" + }, + "include": [ + "./lib/**/*" + ] +}