@@ -149,6 +149,118 @@ namespace CypressCommandsTests {
149149 arg
150150 return cy . wrap ( new Promise < number > ( ( resolve ) => { resolve ( 5 ) } ) )
151151 } )
152+
153+ Cypress . Commands . addAll ( {
154+ newCommand ( arg ) {
155+ // $ExpectType any
156+ arg
157+ this // $ExpectType Context
158+ return
159+ } ,
160+ newCommand2 ( arg , arg2 ) {
161+ // $ExpectType any
162+ arg
163+ // $ExpectType any
164+ arg2
165+ } ,
166+ newCommand3 : ( arg ) => {
167+ // $ExpectType any
168+ arg
169+ return
170+ } ,
171+ newCommand4 : ( arg ) => {
172+ // $ExpectType any
173+ arg
174+ } ,
175+ } )
176+ Cypress . Commands . addAll ( { prevSubject : true } , {
177+ newCommand : ( subject , arg ) => {
178+ subject // $ExpectType unknown
179+ arg // $ExpectType any
180+ return
181+ } ,
182+ } )
183+ Cypress . Commands . addAll ( { prevSubject : false } , {
184+ newCommand : ( arg ) => {
185+ arg // $ExpectType any
186+ return
187+ } ,
188+ } )
189+ Cypress . Commands . addAll ( { prevSubject : 'optional' } , {
190+ newCommand : ( subject , arg ) => {
191+ subject // $ExpectType unknown
192+ arg // $ExpectType any
193+ return
194+ } ,
195+ newCommand2 : ( subject , arg ) => {
196+ subject // $ExpectType unknown
197+ arg // $ExpectType any
198+ } ,
199+ } )
200+ Cypress . Commands . addAll ( { prevSubject : [ 'optional' ] } , {
201+ newCommand : ( subject , arg ) => {
202+ subject // $ExpectType unknown
203+ arg // $ExpectType any
204+ } ,
205+ } )
206+ Cypress . Commands . addAll ( { prevSubject : 'document' } , {
207+ newCommand : ( subject , arg ) => {
208+ subject // $ExpectType Document
209+ arg // $ExpectType any
210+ } ,
211+ } )
212+ Cypress . Commands . addAll ( { prevSubject : 'window' } , {
213+ newCommand : ( subject , arg ) => {
214+ subject // $ExpectType Window
215+ arg // $ExpectType any
216+ } ,
217+ } )
218+ Cypress . Commands . addAll ( { prevSubject : 'element' } , {
219+ newCommand : ( subject , arg ) => {
220+ subject // $ExpectType JQuery<HTMLElement>
221+ arg // $ExpectType any
222+ }
223+ } )
224+ Cypress . Commands . addAll ( { prevSubject : [ 'element' ] } , {
225+ newCommand : ( subject , arg ) => {
226+ subject // $ExpectType JQuery<HTMLElement>
227+ arg // $ExpectType any
228+ }
229+ } )
230+ Cypress . Commands . addAll ( { prevSubject : [ 'element' , 'document' , 'window' ] } , {
231+ newCommand : ( subject , arg ) => {
232+ if ( subject instanceof Window ) {
233+ subject // $ExpectType Window
234+ } else if ( subject instanceof Document ) {
235+ subject // $ExpectType Document
236+ } else {
237+ subject // $ExpectType JQuery<HTMLElement>
238+ }
239+ arg // $ExpectType any
240+ }
241+ } )
242+ Cypress . Commands . addAll ( { prevSubject : [ 'window' , 'document' , 'optional' , 'element' ] } , {
243+ newCommand : ( subject , arg ) => {
244+ if ( subject instanceof Window ) {
245+ subject // $ExpectType Window
246+ } else if ( subject instanceof Document ) {
247+ subject // $ExpectType Document
248+ } else if ( subject ) {
249+ subject // $ExpectType JQuery<HTMLElement>
250+ } else {
251+ subject // $ExpectType void
252+ }
253+ arg // $ExpectType any
254+ }
255+ } )
256+ Cypress . Commands . addAll ( {
257+ newCommand : ( arg ) => {
258+ // $ExpectType any
259+ arg
260+ return cy . wrap ( new Promise < number > ( ( resolve ) => { resolve ( 5 ) } ) )
261+ }
262+ } )
263+
152264 Cypress . Commands . overwrite ( 'newCommand' , ( originalFn , arg ) => {
153265 arg // $ExpectType string
154266 originalFn // $ExpectedType Chainable['newCommand']
0 commit comments