-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Labels
Description
I think this library should include a type to match the OData response signature, as these properties are very important to consider in certain scenarios and I don't think the library consumer should have to define this type themselves or have to rely on another library.
Concretely, I suggest an implementation that ideally enables the following Angular code to compile
(this.http as HttpClient)
.get<ExampleODataType<User>>('https://graph.microsoft.com/v1.0/me')
.subscribe((response) => {
console.log(response['@odata.context']);
console.log(response.displayName);
});
(this.http as HttpClient)
.get<ExampleODataType<User[]>>('https://graph.microsoft.com/v1.0/users?$count')
.subscribe((response) => {
console.log(response['@odata.count']);
console.log(response['@odata.nextLink']);
console.log(response.value[0].displayName);
});
A simpler alternative to this could be a Type containing just the OData properties which one can make intersections with
(this.http as HttpClient)
.get<User & ExampleODataType>('https://graph.microsoft.com/v1.0/me')
.subscribe((response) => {
console.log(response['@odata.context']);
console.log(response.displayName);
});
(this.http as HttpClient)
.get<{ value: User[] } & ExampleODataType>('https://graph.microsoft.com/v1.0/users?$count')
.subscribe((response) => {
console.log(response['@odata.count']);
console.log(response['@odata.nextLink']);
console.log(response.value[0].displayName);
});
erpatterson11, aidenlx and MeroFuruyaSimonSimCity