Suggestion: Generic OData response type

未关闭
#299 1 条评论 5 个 reaction 已指派 1 人 在 GitHub 查看

@nikithauc 已经在做这个了。

开始于 2022年4月5日。

评估

这个 Issue 还没有评估数据。

描述

enhancement

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);
      });  
      
主要语言
PowerShell
星标
129
派生
35
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoftgraph/msgraph-typescript-typings 的其他 Issue

查看 microsoftgraph/msgraph-typescript-typings 的全部 Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。