@@ -28,8 +28,8 @@ export interface IRegistry {
2828 fullName : string ,
2929 optionName : K
3030 ) : TypeOptions [ K ] | undefined ;
31- getOptions ( fullName : string ) : TypeOptions ;
32- getOptionsForType ( type : string ) : TypeOptions ;
31+ getOptions ( fullName : string ) : TypeOptions | undefined ;
32+ getOptionsForType ( type : string ) : TypeOptions | undefined ;
3333 knownForType ( type : string ) : KnownForTypeResult ;
3434 makeToString < T , C > ( factory : Factory < T , C > , fullName : string ) : string ;
3535 normalizeFullName ( fullName : string ) : string ;
@@ -396,7 +396,7 @@ export default class Registry implements IRegistry {
396396 this . _typeOptions [ type ] = options ;
397397 }
398398
399- getOptionsForType ( type : string ) : TypeOptions {
399+ getOptionsForType ( type : string ) : TypeOptions | undefined {
400400 let optionsForType = this . _typeOptions [ type ] ;
401401 if ( optionsForType === undefined && this . fallback !== null ) {
402402 optionsForType = this . fallback . getOptionsForType ( type ) ;
@@ -415,7 +415,7 @@ export default class Registry implements IRegistry {
415415 this . _options [ normalizedName ] = options ;
416416 }
417417
418- getOptions ( fullName : string ) : TypeOptions {
418+ getOptions ( fullName : string ) : TypeOptions | undefined {
419419 let normalizedName = this . normalize ( fullName ) ;
420420 let options = this . _options [ normalizedName ] ;
421421
@@ -436,6 +436,7 @@ export default class Registry implements IRegistry {
436436 }
437437
438438 let type = fullName . split ( ':' ) [ 0 ] ;
439+ assert ( 'has type' , type ) ; // split always will have at least one value
439440 options = this . _typeOptions [ type ] ;
440441
441442 if ( options && options [ optionName ] !== undefined ) {
@@ -484,8 +485,7 @@ export default class Registry implements IRegistry {
484485 knownForType ( type : string ) : KnownForTypeResult {
485486 let localKnown = dictionary ( null ) ;
486487 let registeredNames = Object . keys ( this . registrations ) ;
487- for ( let index = 0 ; index < registeredNames . length ; index ++ ) {
488- let fullName = registeredNames [ index ] ;
488+ for ( let fullName of registeredNames ) {
489489 let itemType = fullName . split ( ':' ) [ 0 ] ;
490490
491491 if ( itemType === type ) {
@@ -522,7 +522,9 @@ if (DEBUG) {
522522
523523 for ( let key in hash ) {
524524 if ( Object . prototype . hasOwnProperty . call ( hash , key ) ) {
525- let { specifier } = hash [ key ] ;
525+ let value = hash [ key ] ;
526+ assert ( 'has value' , value ) ;
527+ let { specifier } = value ;
526528 assert (
527529 `Expected a proper full name, given '${ specifier } '` ,
528530 this . isValidFullName ( specifier )
@@ -543,9 +545,8 @@ if (DEBUG) {
543545 return ;
544546 }
545547
546- for ( let i = 0 ; i < injections . length ; i ++ ) {
547- let { specifier } = injections [ i ] ;
548-
548+ for ( let injection of injections ) {
549+ let { specifier } = injection ;
549550 assert ( `Attempting to inject an unknown injection: '${ specifier } '` , this . has ( specifier ) ) ;
550551 }
551552 } ;
@@ -589,6 +590,8 @@ const privateNames: { [key: string]: string } = dictionary(null);
589590const privateSuffix = `${ Math . random ( ) } ${ Date . now ( ) } ` . replace ( '.' , '' ) ;
590591
591592export function privatize ( [ fullName ] : TemplateStringsArray ) : string {
593+ assert ( 'has a single string argument' , arguments . length === 1 && fullName ) ;
594+
592595 let name = privateNames [ fullName ] ;
593596 if ( name ) {
594597 return name ;
0 commit comments