@@ -41,7 +41,7 @@ export class Headers {
4141 _normalizedNames : Map < string , string > = new Map ( ) ;
4242
4343 // TODO(vicb): any -> string|string[]
44- constructor ( headers ?: Headers | { [ name : string ] : any } ) {
44+ constructor ( headers ?: Headers | { [ name : string ] : any } | null ) {
4545 if ( ! headers ) {
4646 return ;
4747 }
@@ -100,15 +100,16 @@ export class Headers {
100100 this . _headers . delete ( lcName ) ;
101101 }
102102
103- forEach ( fn : ( values : string [ ] , name : string , headers : Map < string , string [ ] > ) => void ) : void {
103+ forEach ( fn : ( values : string [ ] , name : string | undefined , headers : Map < string , string [ ] > ) => void ) :
104+ void {
104105 this . _headers . forEach (
105106 ( values , lcName ) => fn ( values , this . _normalizedNames . get ( lcName ) , this . _headers ) ) ;
106107 }
107108
108109 /**
109110 * Returns first header that matches given name.
110111 */
111- get ( name : string ) : string {
112+ get ( name : string ) : string | null {
112113 const values = this . getAll ( name ) ;
113114
114115 if ( values === null ) {
@@ -157,7 +158,7 @@ export class Headers {
157158 this . _headers . forEach ( ( values : string [ ] , name : string ) => {
158159 const split : string [ ] = [ ] ;
159160 values . forEach ( v => split . push ( ...v . split ( ',' ) ) ) ;
160- serialized [ this . _normalizedNames . get ( name ) ] = split ;
161+ serialized [ this . _normalizedNames . get ( name ) ! ] = split ;
161162 } ) ;
162163
163164 return serialized ;
@@ -166,8 +167,8 @@ export class Headers {
166167 /**
167168 * Returns list of header values for a given name.
168169 */
169- getAll ( name : string ) : string [ ] {
170- return this . has ( name ) ? this . _headers . get ( name . toLowerCase ( ) ) : null ;
170+ getAll ( name : string ) : string [ ] | null {
171+ return this . has ( name ) ? this . _headers . get ( name . toLowerCase ( ) ) || null : null ;
171172 }
172173
173174 /**
0 commit comments