function testStringCollection ( ) { let coll = ( < string [ ] > [ ] ) ; coll . push ( "foobar" ) ; coll . push ( ( 12 ) . toString ( ) ) ; coll . push ( coll [ 0 ] + "xx" ) ; assert ( coll . indexOf ( "12" ) == 1 , "idx" ) ; coll = [ "a" + "b" , coll [ 2 ] , ] ; assert ( coll [ 0 ] == "ab" , "" ) ; assert ( coll [ 1 ] == "foob" + "arxx" , "" ) ; assert ( coll . length == 2 , "" ) ; } function testUnionIndexer ( ) { type SmallNumber = ( 0 | 1 ) | ( 1 | 2 ) | 2 ; const arr = [ "foo" , "bar" , "baz" ] ; let index = 0 ; assert ( arr [ index ] === arr [ 0 ] ) ; index = 1 ; assert ( arr [ index ] === arr [ 1 ] ) ; index = 2 as SmallNumber ; if ( index === 0 ) { return ; } assert ( arr [ index ] === arr [ 2 ] ) ; } testStringCollection ( ) ; testUnionIndexer ( ) ;