@@ -630,13 +630,13 @@ function booleanAttributeControls(formContext: Xrm.FormContext) {
630630 // @ts -expect-error
631631 const notString : string = booleanAttribute . getValue ( ) ;
632632
633- booleanAttribute = booleanAttribute . controls . get ( 0 ) . getAttribute ( ) ;
633+ booleanAttribute = booleanAttribute . controls . get < Xrm . Controls . BooleanControl > ( 0 ) . getAttribute ( ) ;
634634
635635 booleanAttribute . controls . forEach ( ( c : Xrm . Controls . BooleanControl ) => c . setDisabled ( true ) ) ;
636636
637- booleanAttribute . controls . get ( 0 ) . getAttribute ( ) . getAttributeType ( ) === "boolean" ;
637+ booleanAttribute . controls . get < Xrm . Controls . BooleanControl > ( 0 ) . getAttribute ( ) . getAttributeType ( ) === "boolean" ;
638638 // @ts -expect-error
639- booleanAttribute . controls . get ( 0 ) . getAttribute ( ) . getAttributeType ( ) === "optionset" ;
639+ booleanAttribute . controls . get < Xrm . Controls . OptionSetControl > ( 0 ) . getAttribute ( ) . getAttributeType ( ) === "optionset" ;
640640}
641641
642642// Demonstrate add and remove methods for formContext.data.process
@@ -799,3 +799,20 @@ const framedControlSetVisible = (formContext: Xrm.FormContext) => {
799799 // setVisible
800800 framedControl . setVisible ( true ) ;
801801} ;
802+
803+ // Demonstrate ItemCollection.get() overloads
804+ function testItemCollectionGet ( formContext : Xrm . FormContext ) {
805+ // Without explicit type parameter: returns T | null
806+ // $ExpectType Tab | null
807+ formContext . ui . tabs . get ( 0 ) ;
808+
809+ // $ExpectType Tab | null
810+ formContext . ui . tabs . get ( "tabName" ) ;
811+
812+ // With explicit type parameter: returns TSubType (caller asserts item exists)
813+ // $ExpectType Tab
814+ formContext . ui . tabs . get < Xrm . Controls . Tab > ( 0 ) ;
815+
816+ // $ExpectType Tab
817+ formContext . ui . tabs . get < Xrm . Controls . Tab > ( "tabName" ) ;
818+ }
0 commit comments