Typescript errors TS2345 on update method
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- node.js, typescript
- 領域
- database
調査の方向性
まず、型付きインターフェースの例で報告された TS2345 エラーを再現し、DocumentSnapshot と DocumentReference の update エントリポイントを調べます。受け入れられる更新型を MyInterface の例と比較します。型付きインターフェースのデータを any にキャストせずに update に渡せ、関連する型の挙動が検証されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
[READ] Step 1: Are you in the right place?
Yes
[REQUIRED] Step 2: Describe your environment
- Operating System version: Ubuntu 22.04
- Firebase SDK version: 11.11.0
- Firebase Product: firebase-admin
- Node.js version: 18
- NPM version: 9.7.2
[REQUIRED] Step 3: Describe the problem
DocumentSnapshot or DocumentReference update method can't be used with typed interfaces. I get the following typescript error
TS2345: Argument of type MyInterface is not assignable to parameter of type
{ [x: string]: any; } & AddPrefixToKeys<string, any>
Relevant Code:
Calls like this will get errors:
const data = snapshot.data() as MyInterface;
db.collection(`anypath`).doc(id).update(data)
Quick workaround would be to cast it as any
db.collection(`anypath`).doc(id).update(data as any)
But it would require to refactor every update call which can be painful for large projects.
- 主要言語
- TypeScript
- スター
- 1.7k
- フォーク
- 419
- 平均マージ
- 4日 20時間
- マージ済み PR(30日)
- 16
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
firebase/firebase-admin-node のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
firebase/firebase-admin-node#3234 ·
-
firebase/firebase-admin-node#3221 · コメント 3 件 · 担当者 1 名 ·
-
api: messaging
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
難易度 5/5 1週間以上 初心者へのやさしさ 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · コメント 1 件 · 担当者 1 名 ·
firebase/firebase-admin-node の issue をすべて見る
似ている issue
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
Mend: dependency security vulnerability untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100