Skip to content

Typescript: Returned types from firebaseTestEnvironment.authenticatedContext(...).firestore() are incompatible with modular v9 client SDK Firestore types #5550

Closed
@sceee

Description

@sceee

[REQUIRED] Describe your environment

  • Operating System version: Windows 10
  • Browser version: N/A
  • Firebase SDK version: 9.1.0
  • Firebase Product: firestore

[REQUIRED] Describe the problem

In addition to the already fixed #5500, when using the modular v9 client SDK, the "Firestore" type returned by firebaseTestEnvironment.authenticatedContext(...).firestore() from @firebase/rules-unit-testing v2.0.1 is incompatible with the modular client SDK type "Firestore".

Steps to reproduce:

Compile the relevant code below using

  • "@firebase/rules-unit-testing": "2.0.1",
  • "firebase": "9.1.0",

Relevant Code:

import { initializeTestEnvironment, RulesTestEnvironment } from '@firebase/rules-unit-testing'
import { Firestore as ClientFirestore } from 'firebase/firestore'

let db: ClientFirestore
let firebaseTestEnvironment: RulesTestEnvironment

const rulesContent = fs.readFileSync(path.resolve(__dirname, '../../../firestore.rules'), 'utf8')
firebaseTestEnvironment = await initializeTestEnvironment({
      projectId: 'anyproj',
      firestore: {
        rules: rulesContent,
      },
    })

// This line fails to compile with "Type 'Firestore' is missing the following properties from type 'Firestore': type, toJSONts(2739)"
db = firebaseTestEnvironment.authenticatedContext('testuid', {}).firestore()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions