Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore: Using TypeScript Uppercase<string> causes incorrect type error #6918

Closed
jinh0 opened this issue Dec 30, 2022 · 2 comments
Closed
Assignees

Comments

@jinh0
Copy link

jinh0 commented Dec 30, 2022

[REQUIRED] Describe your environment

  • Operating System version: MacOS 12.1
  • Browser version: Safari 15.2
  • Firebase SDK version: 9.14.0
  • Firebase Product: firestore (auth, database, storage, etc)
  • TypeScript version: 4.8.4

[REQUIRED] Describe the problem

Using Uppercase<string> on a type for a CollectionReference causes an error when using updateDoc, when it shouldn't.

Steps to reproduce:

Create a collection reference with an object type with an Uppercase<string> attribute. Then try using updateDoc, and compile with TypeScript. Get the following error:

Type error: Argument of type '{ other: string; }' is not assignable to parameter of type '{ code?: FieldValue | UpdateData<Uppercase<string>>; other?: string | FieldValue; } & UnionToIntersection<ChildUpdateFields<"code", Uppercase<string>>>'.
  Type '{ other: string; }' is not assignable to type 'UnionToIntersection<ChildUpdateFields<"code", Uppercase<string>>>'.

Relevant Code:

type User = {
  code: Uppercase<string>
  other: string
}

let users = collection(firestore, 'users') as CollectionReference<User>

updateDoc(doc(users, 'test-user'), {
  other: 'something',
})```
@cherylEnkidu
Copy link
Contributor

Duplicate of googleapis/nodejs-firestore#1745

Hi,

Thanks for filling the ticket! Our team is aware of this issue and is working on the solution.

@firebase firebase locked and limited conversation to collaborators Feb 3, 2023
@dconeybe
Copy link
Contributor

dconeybe commented Jul 7, 2023

Please check if this was fixed in v10.0.0, as there were several fixes to UpdateData typing issues: https://firebase.google.com/support/release-notes/js#version_1000_-_july_6_2023

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants