Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Typescript errors TS2345 on update method

オープン
#2,372 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
node.js, typescript
領域
database

調査の方向性

まず、型付きインターフェースの例で報告された TS2345 エラーを再現し、DocumentSnapshot と DocumentReference の update エントリポイントを調べます。受け入れられる更新型を MyInterface の例と比較します。型付きインターフェースのデータを any にキャストせずに update に渡せ、関連する型の挙動が検証されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

needs-triage
[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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

firebase/firebase-admin-node のほかの issue

firebase/firebase-admin-node の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。