@@ -1311,12 +1311,13 @@ namespace ts {
13111311 * the same key with the given 'makeKey' function, then the element with the higher
13121312 * index in the array will be the one associated with the produced key.
13131313 */
1314- export function arrayToMap < T > ( array : ReadonlyArray < T > , makeKey : ( value : T ) => string ) : Map < T > ;
1315- export function arrayToMap < T , U > ( array : ReadonlyArray < T > , makeKey : ( value : T ) => string , makeValue : ( value : T ) => U ) : Map < U > ;
1316- export function arrayToMap < T , U > ( array : ReadonlyArray < T > , makeKey : ( value : T ) => string , makeValue : ( value : T ) => T | U = identity ) : Map < T | U > {
1314+ export function arrayToMap < T > ( array : ReadonlyArray < T > , makeKey : ( value : T ) => string | undefined ) : Map < T > ;
1315+ export function arrayToMap < T , U > ( array : ReadonlyArray < T > , makeKey : ( value : T ) => string | undefined , makeValue : ( value : T ) => U ) : Map < U > ;
1316+ export function arrayToMap < T , U > ( array : ReadonlyArray < T > , makeKey : ( value : T ) => string | undefined , makeValue : ( value : T ) => T | U = identity ) : Map < T | U > {
13171317 const result = createMap < T | U > ( ) ;
13181318 for ( const value of array ) {
1319- result . set ( makeKey ( value ) , makeValue ( value ) ) ;
1319+ const key = makeKey ( value ) ;
1320+ if ( key !== undefined ) result . set ( key , makeValue ( value ) ) ;
13201321 }
13211322 return result ;
13221323 }
@@ -1337,8 +1338,9 @@ namespace ts {
13371338 * @param array the array of input elements.
13381339 */
13391340 export function arrayToSet ( array : ReadonlyArray < string > ) : Map < true > ;
1340- export function arrayToSet < T > ( array : ReadonlyArray < T > , makeKey : ( value : T ) => string ) : Map < true > ;
1341- export function arrayToSet ( array : ReadonlyArray < any > , makeKey ?: ( value : any ) => string ) : Map < true > {
1341+ export function arrayToSet < T > ( array : ReadonlyArray < T > , makeKey : ( value : T ) => string | undefined ) : Map < true > ;
1342+ export function arrayToSet < T > ( array : ReadonlyArray < T > , makeKey : ( value : T ) => __String | undefined ) : UnderscoreEscapedMap < true > ;
1343+ export function arrayToSet ( array : ReadonlyArray < any > , makeKey ?: ( value : any ) => string | __String | undefined ) : Map < true > | UnderscoreEscapedMap < true > {
13421344 return arrayToMap < any , true > ( array , makeKey || ( s => s ) , ( ) => true ) ;
13431345 }
13441346
0 commit comments