Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Typescript errors TS2345 on update method

Open
#2,372 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
node.js, typescript
Domain
database

Research direction

Start by reproducing the reported TS2345 error with the typed-interface example and inspect the DocumentSnapshot and DocumentReference update entry points. Compare the accepted update types with the MyInterface example. Done means typed interface data can be passed to update without casting to any, with the relevant type behavior verified.

Written by the indexing model from the issue text.

Description

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.

Dominant language
TypeScript
Stars
1.7k
Forks
419
Avg merge
4d 20h
Merged PRs (30d)
16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-admin-node

All issues in firebase/firebase-admin-node

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.