@@ -17,11 +17,11 @@ export function extractOdataId(candidate: any): string {
1717 }
1818}
1919
20- export interface ODataParser < T , U > {
20+ export interface ODataParser < U > {
2121 parse ( r : Response ) : Promise < U > ;
2222}
2323
24- export abstract class ODataParserBase < T , U > implements ODataParser < T , U > {
24+ export abstract class ODataParserBase < U > implements ODataParser < U > {
2525
2626 public parse ( r : Response ) : Promise < U > {
2727 return r . json ( ) . then ( json => this . parseODataJSON ( json ) ) ;
@@ -42,36 +42,36 @@ export abstract class ODataParserBase<T, U> implements ODataParser<T, U> {
4242 }
4343}
4444
45- export class ODataDefaultParser extends ODataParserBase < any , any > {
45+ export class ODataDefaultParser extends ODataParserBase < any > {
4646}
4747
48- export class ODataRawParserImpl implements ODataParser < any , any > {
48+ export class ODataRawParserImpl implements ODataParser < any > {
4949 public parse ( r : Response ) : Promise < any > {
5050 return r . json ( ) ;
5151 }
5252}
5353
54- class ODataValueParserImpl < T > extends ODataParserBase < any , T > {
54+ class ODataValueParserImpl < T > extends ODataParserBase < T > {
5555 public parse ( r : Response ) : Promise < T > {
5656 return super . parse ( r ) . then ( d => d as T ) ;
5757 }
5858}
5959
60- class ODataEntityParserImpl < T > extends ODataParserBase < T , T > {
60+ class ODataEntityParserImpl < T > extends ODataParserBase < T > {
6161
6262 constructor ( protected factory : QueryableConstructor < T > ) {
6363 super ( ) ;
6464 }
6565
6666 public parse ( r : Response ) : Promise < T > {
6767 return super . parse ( r ) . then ( d => {
68- let o = new this . factory ( getEntityUrl ( d ) , null ) ;
68+ let o = < T > new this . factory ( getEntityUrl ( d ) , null ) ;
6969 return Util . extend ( o , d ) ;
7070 } ) ;
7171 }
7272}
7373
74- class ODataEntityArrayParserImpl < T > extends ODataParserBase < T , T [ ] > {
74+ class ODataEntityArrayParserImpl < T > extends ODataParserBase < T [ ] > {
7575
7676 constructor ( protected factory : QueryableConstructor < T > ) {
7777 super ( ) ;
@@ -80,7 +80,7 @@ class ODataEntityArrayParserImpl<T> extends ODataParserBase<T, T[]> {
8080 public parse ( r : Response ) : Promise < T [ ] > {
8181 return super . parse ( r ) . then ( ( d : any [ ] ) => {
8282 return d . map ( v => {
83- let o = new this . factory ( getEntityUrl ( v ) , null ) ;
83+ let o = < T > new this . factory ( getEntityUrl ( v ) , null ) ;
8484 return Util . extend ( o , v ) ;
8585 } ) ;
8686 } ) ;
@@ -89,12 +89,12 @@ class ODataEntityArrayParserImpl<T> extends ODataParserBase<T, T[]> {
8989
9090function getEntityUrl ( entity : any ) : string {
9191
92- if ( entity . hasOwnProperty ( "__metadata" ) ) {
93- // we are dealing with verbose, which has an absolute uri
94- return entity . __metadata . uri ;
95- } else if ( entity . hasOwnProperty ( "odata.editLink" ) ) {
92+ if ( entity . hasOwnProperty ( "odata.editLink" ) ) {
9693 // we are dealign with minimal metadata (default)
9794 return Util . combinePaths ( "_api" , entity [ "odata.editLink" ] ) ;
95+ } else if ( entity . hasOwnProperty ( "__metadata" ) ) {
96+ // we are dealing with verbose, which has an absolute uri
97+ return entity . __metadata . uri ;
9898 } else {
9999 // we are likely dealing with nometadata, so don't error but we won't be able to
100100 // chain off these objects
@@ -105,16 +105,16 @@ function getEntityUrl(entity: any): string {
105105
106106export let ODataRaw = new ODataRawParserImpl ( ) ;
107107
108- export function ODataValue < T > ( ) : ODataParser < any , T > {
108+ export function ODataValue < T > ( ) : ODataParser < T > {
109109 return new ODataValueParserImpl < T > ( ) ;
110110}
111111
112- export function ODataEntity < T > ( factory : QueryableConstructor < T > ) : ODataParser < T , T > {
112+ export function ODataEntity < T > ( factory : QueryableConstructor < T > ) : ODataParser < T > {
113113 return new ODataEntityParserImpl ( factory ) ;
114114}
115115
116- export function ODataEntityArray < T > ( factory : QueryableConstructor < T > ) : ODataParser < T , T [ ] > {
117- return new ODataEntityArrayParserImpl < T > ( factory ) ;
116+ export function ODataEntityArray < T > ( factory : QueryableConstructor < T > ) : ODataParser < T [ ] > {
117+ return new ODataEntityArrayParserImpl ( factory ) ;
118118}
119119
120120/**
@@ -138,18 +138,18 @@ export class ODataBatch {
138138 * @param options Any options to include in the request
139139 * @param parser The parser that will hadle the results of the request
140140 */
141- public add < U > ( url : string , method : string , options : any , parser : ODataParser < any , U > ) : Promise < U > {
141+ public add < T > ( url : string , method : string , options : any , parser : ODataParser < T > ) : Promise < T > {
142142
143143 let info = {
144144 method : method . toUpperCase ( ) ,
145145 options : options ,
146146 parser : parser ,
147147 reject : < ( reason ?: any ) => void > null ,
148- resolve : < ( value ?: U | PromiseLike < U > ) => void > null ,
148+ resolve : < ( value ?: T | PromiseLike < T > ) => void > null ,
149149 url : url ,
150150 } ;
151151
152- let p = new Promise < U > ( ( resolve , reject ) => {
152+ let p = new Promise < T > ( ( resolve , reject ) => {
153153 info . resolve = resolve ;
154154 info . reject = reject ;
155155 } ) ;
@@ -369,33 +369,33 @@ interface ODataBatchRequestInfo {
369369 url : string ;
370370 method : string ;
371371 options : any ;
372- parser : ODataParser < any , any > ;
372+ parser : ODataParser < any > ;
373373 resolve : ( d : any ) => void ;
374374 reject : ( error : any ) => void ;
375375}
376376
377- export class TextFileParser implements ODataParser < any , string > {
377+ export class TextFileParser implements ODataParser < string > {
378378
379379 public parse ( r : Response ) : Promise < string > {
380380 return r . text ( ) ;
381381 }
382382}
383383
384- export class BlobFileParser implements ODataParser < any , Blob > {
384+ export class BlobFileParser implements ODataParser < Blob > {
385385
386386 public parse ( r : Response ) : Promise < Blob > {
387387 return r . blob ( ) ;
388388 }
389389}
390390
391- export class JSONFileParser implements ODataParser < any , any > {
391+ export class JSONFileParser implements ODataParser < any > {
392392
393393 public parse ( r : Response ) : Promise < any > {
394394 return r . json ( ) ;
395395 }
396396}
397397
398- export class BufferFileParser implements ODataParser < any , ArrayBuffer > {
398+ export class BufferFileParser implements ODataParser < ArrayBuffer > {
399399
400400 public parse ( r : any ) : Promise < ArrayBuffer > {
401401
0 commit comments