Argument of type '"blob"' is not assignable to parameter of type 'ResponseType' in SPFX project
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 38/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- typescript
- 領域
- api
調査の方向性
Start with the responseType("blob") call in src/webparts/helloWorld/HelloWorldWebPart.ts and inspect the @microsoft/sp-http 1.18.2 types used by MSGraphClientV3. Run gulp serve to reproduce the TypeScript error; done means the blob response type is accepted and the sample builds successfully.
索引モデルが issue の本文から書いたものです。
説明
Bug Report
Hello, I've created a new web part in my SPFX project and my SPFX package version was upgraded from 1.17 to 1.18 automatically by the creation wizard.
This seem to have brought a breaking change with existing Microsoft Graph code used in the project.
Prerequisites
- Can you reproduce the problem?
- Are you running the latest version?
- Are you reporting to the correct repository?
- Did you perform a cursory search?
For more information, see the CONTRIBUTING guide.
Description
Here is my code:
private async _getUserProfilePicture(): Promise<HTMLImageElement | void> {
return await this.context.msGraphClientFactory.getClient('3').then(
async (graphclient: MSGraphClientV3) => {
return await graphclient
.api('/me/photo/$value')
.responseType("blob")
.get()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.then((blob: Blob): Promise<any> => {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => {
const b64 = await blobToBase64(blob);
const img = new Image();
img.src = b64;
this.properties.hasProfilePicture = true;
return resolve(img);
});
})
.catch((e) => {
// ...
});
});
And the IDE error:
Argument of type '"blob"' is not assignable to parameter of type 'ResponseType'.ts(2345)
Console Errors: [Is there any console error]
Screenshots: [If applicable, add screenshots to help explain your problem]
Steps to Reproduce
- Create a new folder and initialize a new SPFX solution:
yo @microsoft/sharepoint - Choose WebPart for the client-side component and React for template, leave everything else default
- Install the @microsoft/sp-http package for the MSGraphClientV3:
npm i @microsoft/sp-http - Modify config/serve.json with your SharePoint tenant URL
- Open up
src/webparts/helloWorld/HelloWorldWebPart.ts - Modify the
onInitmethod to look like this:
protected async onInit(): Promise<void> {
await this.context.msGraphClientFactory.getClient('3').then(
async (graphclient: MSGraphClientV3) => {
return await graphclient
.api('/me/photo/$value')
.responseType("blob")
.get()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.then((blob: Blob): Promise<any> => {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (resolve, reject) => {
return resolve(blob);
});
})
});
}
- Run the
gulp servecommand - The build will fail:
Error - [tsc] src/webparts/helloWorld/HelloWorldWebPart.ts(45,25): error TS2345: Argument of type '"blob"' is not assignable to parameter of type 'ResponseType'.
Expected behavior: [What you expected to happen]
The string "blob" to be accepted as an argument for responseType method on the GraphRequest.
Actual behavior: [What actually happened]
Cannot build because of error.
Additional Context
"@microsoft/sp-http": "^1.18.2" was installed
Usage Information
Request ID - Value of the requestId field if you are receiving a Graph API error response
SDK Version - [SDK version you are using]
- Node (Check, if using Node version of SDK)
Node Version - 18
- Browser (Check, if using Browser version of SDK)
Browser Name - [The name of Browser that you are using for SDK]
Version - [The version of the browser you are using]
- 主要言語
- TypeScript
- スター
- 833
- フォーク
- 240
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoftgraph/msgraph-sdk-javascript のほかの issue
-
status:waiting-for-triage
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
-
Is anyone here? オープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
microsoftgraph/msgraph-sdk-javascript#2005 · リアクション 1 件 ·
-
Is it really correct that the Javascript version of the graph SDK doesn't offer typed requests? オープンstatus:waiting-for-triage
難易度 5/5 1週間以上 初心者へのやさしさ 42/100
-
status:waiting-for-triage type:bug
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
microsoftgraph/msgraph-sdk-javascript#1999 · コメント 2 件 · リアクション 1 件 ·
-
status:waiting-for-triage type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
microsoftgraph/msgraph-sdk-javascript の issue をすべて見る
似ている issue
-
clawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
ZCode 3.14.3 に対応する オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
supermomonga/zcode-acp#24 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
growthbook/growthbook#7100 ·
-
triage
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100