55 * MIT Licensed
66 */
77
8- import { config } from "./config.js" ;
9- import { AssertionError } from "assertion-error" ;
10- import * as util from "./utils/index.js" ;
8+ import { config } from './config.js' ;
9+ import { AssertionError } from 'assertion-error' ;
10+ import * as util from './utils/index.js' ;
11+
12+ export class Assertion {
13+ /** @type {{} } */
14+ __flags = { }
1115
1216/**
1317 * Creates object for chaining.
@@ -39,51 +43,49 @@ import * as util from "./utils/index.js";
3943 *
4044 * - `eql`: This flag contains the deepEqual function to be used by the assertion.
4145 *
42- * @param {unknown } ?obj target of the assertion
43- * @param {string } ?msg (optional) custom error message
44- * @param {Function } ?ssfi (optional) starting point for removing stack frames
45- * @param {boolean } ?lockSsfi (optional) whether or not the ssfi flag is locked
46- * @returns {unknown }
46+ * @param {unknown } obj target of the assertion
47+ * @param {string } [msg] (optional) custom error message
48+ * @param {Function } [ssfi] (optional) starting point for removing stack frames
49+ * @param {boolean } [lockSsfi] (optional) whether or not the ssfi flag is locked
4750 */
48- export class Assertion {
4951 constructor ( obj , msg , ssfi , lockSsfi ) {
50- util . flag ( this , " ssfi" , ssfi || Assertion ) ;
51- util . flag ( this , " lockSsfi" , lockSsfi ) ;
52- util . flag ( this , " object" , obj ) ;
53- util . flag ( this , " message" , msg ) ;
54- util . flag ( this , " eql" , config . deepEqual || util . eql ) ;
52+ util . flag ( this , ' ssfi' , ssfi || Assertion ) ;
53+ util . flag ( this , ' lockSsfi' , lockSsfi ) ;
54+ util . flag ( this , ' object' , obj ) ;
55+ util . flag ( this , ' message' , msg ) ;
56+ util . flag ( this , ' eql' , config . deepEqual || util . eql ) ;
5557
5658 return util . proxify ( this ) ;
5759 }
5860
5961 /** @returns {boolean } */
6062 static get includeStack ( ) {
6163 console . warn (
62- " Assertion.includeStack is deprecated, use chai.config.includeStack instead." ,
64+ ' Assertion.includeStack is deprecated, use chai.config.includeStack instead.'
6365 ) ;
6466 return config . includeStack ;
6567 }
6668
6769 /** @param {boolean } value */
6870 static set includeStack ( value ) {
6971 console . warn (
70- " Assertion.includeStack is deprecated, use chai.config.includeStack instead." ,
72+ ' Assertion.includeStack is deprecated, use chai.config.includeStack instead.'
7173 ) ;
7274 config . includeStack = value ;
7375 }
7476
7577 /** @returns {boolean } */
7678 static get showDiff ( ) {
7779 console . warn (
78- " Assertion.showDiff is deprecated, use chai.config.showDiff instead." ,
80+ ' Assertion.showDiff is deprecated, use chai.config.showDiff instead.'
7981 ) ;
8082 return config . showDiff ;
8183 }
8284
8385 /** @param {boolean } value */
8486 static set showDiff ( value ) {
8587 console . warn (
86- " Assertion.showDiff is deprecated, use chai.config.showDiff instead." ,
88+ ' Assertion.showDiff is deprecated, use chai.config.showDiff instead.'
8789 ) ;
8890 config . showDiff = value ;
8991 }
@@ -150,6 +152,7 @@ export class Assertion {
150152 * @param {unknown } expected value (remember to check for negation)
151153 * @param {unknown } _actual (optional) will default to `this.obj`
152154 * @param {boolean } showDiff (optional) when set to `true`, assert will display a diff in addition to the message if expression fails
155+ * @returns {void }
153156 */
154157 assert ( _expr , msg , _negateMsg , expected , _actual , showDiff ) {
155158 var ok = util . test ( this , arguments ) ;
@@ -160,10 +163,11 @@ export class Assertion {
160163 if ( ! ok ) {
161164 msg = util . getMessage ( this , arguments ) ;
162165 var actual = util . getActual ( this , arguments ) ;
166+ /** @type {Record<PropertyKey, unknown> } */
163167 var assertionErrorObjectProperties = {
164168 actual : actual ,
165169 expected : expected ,
166- showDiff : showDiff ,
170+ showDiff : showDiff
167171 } ;
168172
169173 var operator = util . getOperator ( this , arguments ) ;
@@ -174,7 +178,8 @@ export class Assertion {
174178 throw new AssertionError (
175179 msg ,
176180 assertionErrorObjectProperties ,
177- config . includeStack ? this . assert : util . flag ( this , "ssfi" ) ,
181+ // @ts -expect-error Not sure what to do about these types yet
182+ config . includeStack ? this . assert : util . flag ( this , 'ssfi' )
178183 ) ;
179184 }
180185 }
@@ -185,7 +190,7 @@ export class Assertion {
185190 * @returns {unknown }
186191 */
187192 get _obj ( ) {
188- return util . flag ( this , " object" ) ;
193+ return util . flag ( this , ' object' ) ;
189194 }
190195
191196 /**
@@ -194,6 +199,6 @@ export class Assertion {
194199 * @param {unknown } val
195200 */
196201 set _obj ( val ) {
197- util . flag ( this , " object" , val ) ;
202+ util . flag ( this , ' object' , val ) ;
198203 }
199204}
0 commit comments