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