1
- // @ts -nocheck
2
-
3
1
import _ from 'lodash'
4
2
import Promise from 'bluebird'
5
3
@@ -54,12 +52,18 @@ const isDomSubjectAndMatchesValue = (value, subject) => {
54
52
return false
55
53
}
56
54
55
+ type Parsed = {
56
+ subject ?: any
57
+ actual ?: any
58
+ expected ?: any
59
+ }
60
+
57
61
// Rules:
58
62
// 1. always remove value
59
63
// 2. if value is a jquery object set a subject
60
64
// 3. if actual is undefined or its not expected remove both actual + expected
61
65
const parseValueActualAndExpected = ( value , actual , expected ) => {
62
- const obj = { actual, expected }
66
+ const obj : Parsed = { actual, expected }
63
67
64
68
if ( $dom . isJquery ( value ) ) {
65
69
obj . subject = value
@@ -77,7 +81,7 @@ export const create = (Cypress, cy) => {
77
81
const getUpcomingAssertions = ( ) => {
78
82
const index = cy . state ( 'index' ) + 1
79
83
80
- const assertions = [ ]
84
+ const assertions : any [ ] = [ ]
81
85
82
86
// grab the rest of the queue'd commands
83
87
for ( let cmd of cy . queue . slice ( index ) ) {
@@ -137,7 +141,11 @@ export const create = (Cypress, cy) => {
137
141
message = message . replace ( stackTracesRe , '\n' )
138
142
}
139
143
140
- let obj = parseValueActualAndExpected ( value , actual , expected )
144
+ let parsed = parseValueActualAndExpected ( value , actual , expected )
145
+ // TODO: make it more specific after defining the type for Cypress.log().
146
+ let obj : Record < string , any > = {
147
+ ...parsed ,
148
+ }
141
149
142
150
if ( $dom . isElement ( value ) ) {
143
151
obj . $el = $dom . wrap ( value )
@@ -216,10 +224,18 @@ export const create = (Cypress, cy) => {
216
224
} )
217
225
}
218
226
227
+ type VerifyUpcomingAssertionsCallbacks = {
228
+ ensureExistenceFor ?: 'subject' | 'dom' | boolean
229
+ onPass ?: Function
230
+ onFail ?: ( err ?, isDefaultAssertionErr ?: boolean , cmds ?: any [ ] ) => void
231
+ onRetry ?: ( ) => any
232
+ }
233
+
219
234
return {
220
235
finishAssertions,
221
236
222
- verifyUpcomingAssertions ( subject , options = { } , callbacks = { } ) {
237
+ // TODO: define the specific type of options
238
+ verifyUpcomingAssertions ( subject , options : Record < string , any > = { } , callbacks : VerifyUpcomingAssertionsCallbacks = { } ) {
223
239
const cmds = getUpcomingAssertions ( )
224
240
225
241
cy . state ( 'upcomingAssertions' , cmds )
@@ -433,12 +449,13 @@ export const create = (Cypress, cy) => {
433
449
cy . state ( 'onBeforeLog' , setCommandLog )
434
450
435
451
// send verify=true as the last arg
436
- return assertFn . apply ( this , args . concat ( true ) )
452
+ return assertFn . apply ( this , args . concat ( true ) as any )
437
453
}
438
454
439
455
const fns = injectAssertionFns ( cmds )
440
456
441
- const subjects = [ ]
457
+ // TODO: remove any when the type of subject, the first argument of this function is specified.
458
+ const subjects : any [ ] = [ ]
442
459
443
460
// iterate through each subject
444
461
// and force the assertion to return
0 commit comments