Skip to content

Inconvenient type of UserRecord.customClaims #864

Closed
andy0937/firebase-admin-node
#1
@anantakrishna

Description

@anantakrishna

Environment

  • Operating System version: Windows
  • Firebase SDK version: 8.11.0
  • Firebase Product: auth
  • Node.js version: 10.20.1
  • NPM version: 6.14.4

The problem

Typing of UserRecord.customClaims is Object.
This is inconvenient to use typescript optional chaining in this case.

const user = await admin.auth().getUser(uid);
if (user.customClaims?.roles?.coordinator)
  …

Produces the following error:

Property 'roles' does not exist on type 'Object'.ts(2339)

This contrasts to the DecodedIdToken which has [key: string]: any; indexer.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions