@@ -292,13 +292,24 @@ test('7-subcommand-basic-options', () => {
292292 /** interaction.options.get is never */
293293 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . toBeNever ( ) ;
294294
295+ /** interaction.options.getSubcommand() narrows down properly */
296+ if (
297+ isTyped . subcommand ( interaction , '7-subcommand-1' ) ||
298+ isTyped . subcommand ( interaction , '7-subcommand-2' ) ||
299+ isTyped . subcommand ( interaction , '7-subcommand-3-empty' )
300+ ) {
301+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '7-subcommand-1' | '7-subcommand-2' | '7-subcommand-3-empty' > ( ) ;
302+ }
303+
295304 if ( isTyped . subcommand ( interaction , '7-subcommand-1' ) ) {
296305 /** interaction matches subcommand */
297306 expectTypeOf ( interaction ) . toEqualTypeOf < TypedSubcommand < typeof commands , '7-subcommand-basic-options' , '7-subcommand-1' > > ( ) ;
298307 /** interaction.options.get is not never */
299308 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . not . toBeNever ( ) ;
300309 /** interaction.options.get is not never */
301310 expectTypeOf ( interaction . options . get ( '7-sub-1-string' ) . name ) . toEqualTypeOf < '7-sub-1-string' > ( ) ;
311+ /** interaction.options.getSubcommand() narrows down properly */
312+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '7-subcommand-1' > ( ) ;
302313 /** interaction.options.get can't access sibling options */
303314 /** @ts -expect-error */
304315 interaction . options . get ( '7-sub-2-string' ) ;
@@ -311,6 +322,8 @@ test('7-subcommand-basic-options', () => {
311322 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . not . toBeNever ( ) ;
312323 /** interaction.options.get is not never */
313324 expectTypeOf ( interaction . options . get ( '7-sub-2-string' ) . name ) . toEqualTypeOf < '7-sub-2-string' > ( ) ;
325+ /** interaction.options.getSubcommand() narrows down properly */
326+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '7-subcommand-2' > ( ) ;
314327 /** interaction.options.get can't access sibling options */
315328 /** @ts -expect-error */
316329 interaction . options . get ( '7-sub-1-string' ) ;
@@ -321,6 +334,8 @@ test('7-subcommand-basic-options', () => {
321334 expectTypeOf ( interaction ) . toEqualTypeOf < TypedSubcommand < typeof commands , '7-subcommand-basic-options' , '7-subcommand-3-empty' > > ( ) ;
322335 /** interaction.options.get is never */
323336 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . toBeNever ( ) ;
337+ /** interaction.options.getSubcommand() narrows down properly */
338+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '7-subcommand-3-empty' > ( ) ;
324339 /** interaction.options.get can't access sibling options */
325340 /** @ts -expect-error */
326341 interaction . options . get ( '7-sub-1-string' ) ;
@@ -424,9 +439,22 @@ test('10-subgroup', () => {
424439 /** interaction.options.get is never */
425440 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . toBeNever ( ) ;
426441
442+ if (
443+ isTyped . subcommand ( interaction , '10-subgroup-1-subcommand-1' ) ||
444+ isTyped . subcommand ( interaction , '10-subgroup-1-subcommand-2' ) ||
445+ isTyped . subcommand ( interaction , '10-subgroup-2-subcommand-1' ) ||
446+ isTyped . subcommand ( interaction , '10-subgroup-2-subcommand-2' ) ||
447+ isTyped . subcommand ( interaction , '10-subgroup-4-empty-subcommand-1' ) ||
448+ isTyped . subcommand ( interaction , '10-subgroup-4-empty-subcommand-2' )
449+ ) {
450+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '10-subgroup-1-subcommand-1' | '10-subgroup-1-subcommand-2' | '10-subgroup-2-subcommand-1' | '10-subgroup-2-subcommand-2' | '10-subgroup-4-empty-subcommand-1' | '10-subgroup-4-empty-subcommand-2' > ( ) ;
451+ }
452+
427453 if ( isTyped . subcommand ( interaction , '10-subgroup-1-subcommand-1' ) ) {
428454 /** interaction.options.get is not never */
429455 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . not . toBeNever ( ) ;
456+ /** interaction.options.getSubcommand() narrows down properly */
457+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '10-subgroup-1-subcommand-1' > ( ) ;
430458 /** interaction.options.get can't access sibling options */
431459 /** @ts -expect-error */
432460 interaction . options . get ( '10-s2-s2-integer' ) ;
@@ -435,6 +463,8 @@ test('10-subgroup', () => {
435463 if ( isTyped . subcommand ( interaction , '10-subgroup-1-subcommand-2' ) ) {
436464 /** interaction.options.get is not never */
437465 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . not . toBeNever ( ) ;
466+ /** interaction.options.getSubcommand() narrows down properly */
467+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '10-subgroup-1-subcommand-2' > ( ) ;
438468 /** interaction.options.get can't access sibling options */
439469 /** @ts -expect-error */
440470 interaction . options . get ( '10-s1-s1-integer' ) ;
@@ -443,6 +473,8 @@ test('10-subgroup', () => {
443473 if ( isTyped . subcommand ( interaction , '10-subgroup-2-subcommand-1' ) ) {
444474 /** interaction.options.get is not never */
445475 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . not . toBeNever ( ) ;
476+ /** interaction.options.getSubcommand() narrows down properly */
477+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '10-subgroup-2-subcommand-1' > ( ) ;
446478 /** interaction.options.get can't access sibling options */
447479 /** @ts -expect-error */
448480 interaction . options . get ( '10-s1-s1-integer' ) ;
@@ -451,6 +483,8 @@ test('10-subgroup', () => {
451483 if ( isTyped . subcommand ( interaction , '10-subgroup-2-subcommand-2' ) ) {
452484 /** interaction.options.get is not never */
453485 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . not . toBeNever ( ) ;
486+ /** interaction.options.getSubcommand() narrows down properly */
487+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '10-subgroup-2-subcommand-2' > ( ) ;
454488 /** interaction.options.get can't access sibling options */
455489 /** @ts -expect-error */
456490 interaction . options . get ( '10-s1-s1-integer' ) ;
@@ -459,6 +493,8 @@ test('10-subgroup', () => {
459493 if ( isTyped . subcommand ( interaction , '10-subgroup-4-empty-subcommand-1' ) ) {
460494 /** interaction.options.get is never */
461495 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . toBeNever ( ) ;
496+ /** interaction.options.getSubcommand() narrows down properly */
497+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '10-subgroup-4-empty-subcommand-1' > ( ) ;
462498 /** interaction.options.get can't access sibling options */
463499 /** @ts -expect-error */
464500 interaction . options . get ( '10-s1-s1-integer' ) ;
@@ -467,6 +503,8 @@ test('10-subgroup', () => {
467503 if ( isTyped . subcommand ( interaction , '10-subgroup-4-empty-subcommand-2' ) ) {
468504 /** interaction.options.get is never */
469505 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . toBeNever ( ) ;
506+ /** interaction.options.getSubcommand() narrows down properly */
507+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '10-subgroup-4-empty-subcommand-2' > ( ) ;
470508 /** interaction.options.get can't access sibling options */
471509 /** @ts -expect-error */
472510 interaction . options . get ( '10-s1-s1-integer' ) ;
@@ -492,30 +530,48 @@ test('11-subgroup-subcommand-sibling', () => {
492530 /** interaction matches command */
493531 expectTypeOf ( interaction ) . toEqualTypeOf < Command [ '11-subgroup-subcommand-sibling' ] > ( ) ;
494532
533+ if (
534+ isTyped . subcommand ( interaction , '11-subcommand-sibling' ) ||
535+ isTyped . subcommand ( interaction , '11-subcommand-sibling-empty' ) ||
536+ isTyped . subcommand ( interaction , '11-sugroup-1-subcommand-1' ) ||
537+ isTyped . subcommand ( interaction , '11-sugroup-1-subcommand-2' ) ||
538+ isTyped . subcommand ( interaction , '11-sugroup-1-subcommand-3-empty' )
539+ ) {
540+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '11-sugroup-1-subcommand-1' | '11-sugroup-1-subcommand-2' | '11-sugroup-1-subcommand-3-empty' | '11-subcommand-sibling' | '11-subcommand-sibling-empty' > ( ) ;
541+ }
542+
495543 if ( isTyped . subcommand ( interaction , '11-sugroup-1-subcommand-1' ) ) {
496544 /** interaction.options.get is not never */
497545 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . not . toBeNever ( ) ;
546+ /** interaction.options.getSubcommand() narrows down properly */
547+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '11-sugroup-1-subcommand-1' > ( ) ;
498548 /** interaction.options.get can't access sibling options */
499549 /** @ts -expect-error */
500550 interaction . options . get ( '11-s1-s2-integer' ) ;
501551 }
502552 if ( isTyped . subcommand ( interaction , '11-sugroup-1-subcommand-2' ) ) {
503553 /** interaction.options.get is not never */
504554 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . not . toBeNever ( ) ;
555+ /** interaction.options.getSubcommand() narrows down properly */
556+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '11-sugroup-1-subcommand-2' > ( ) ;
505557 /** interaction.options.get can't access sibling options */
506558 /** @ts -expect-error */
507559 interaction . options . get ( '11-s1-s1-integer' ) ;
508560 }
509561 if ( isTyped . subcommand ( interaction , '11-sugroup-1-subcommand-3-empty' ) ) {
510562 /** interaction.options.get is never */
511563 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . toBeNever ( ) ;
564+ /** interaction.options.getSubcommand() narrows down properly */
565+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '11-sugroup-1-subcommand-3-empty' > ( ) ;
512566 /** interaction.options.get can't access sibling options */
513567 /** @ts -expect-error */
514568 interaction . options . get ( '11-s1-s1-integer' ) ;
515569 }
516570 if ( isTyped . subcommand ( interaction , '11-subcommand-sibling' ) ) {
517571 /** interaction.options.get is not never */
518572 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . not . toBeNever ( ) ;
573+ /** interaction.options.getSubcommand() narrows down properly */
574+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '11-subcommand-sibling' > ( ) ;
519575 /** interaction.options.get can't access sibling options */
520576 /** @ts -expect-error */
521577 interaction . options . get ( '11-s1-s1-integer' ) ;
@@ -524,6 +580,8 @@ test('11-subgroup-subcommand-sibling', () => {
524580 if ( isTyped . subcommand ( interaction , '11-subcommand-sibling-empty' ) ) {
525581 /** interaction.options.get is never */
526582 expectTypeOf < Parameters < typeof interaction [ 'options' ] [ 'get' ] > [ 0 ] > ( ) . toBeNever ( ) ;
583+ /** interaction.options.getSubcommand() narrows down properly */
584+ expectTypeOf ( interaction . options . getSubcommand ( ) ) . toEqualTypeOf < '11-subcommand-sibling-empty' > ( ) ;
527585 /** interaction.options.get can't access sibling options */
528586 /** @ts -expect-error */
529587 interaction . options . get ( '11-s1-s1-integer' ) ;
0 commit comments