Typescript errors TS2345 on update method
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
[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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/firebase-admin-node
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
firebase/firebase-admin-node#3234 ·
-
firebase/firebase-admin-node#3221 · 3 comments · 1 assignee ·
-
api: messaging
Difficulty 3/5 1-2 days Newbie friendliness 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
Difficulty 5/5 Over a week Newbie friendliness 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 comment · 1 assignee ·
All issues in firebase/firebase-admin-node
Similar issues
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Mend: dependency security vulnerability untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 70/100