setPersistence in AngularFire _BrowserLocalPersistence cannot be invoked without 'new'`

Open
#3,550 3 comments 5 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
43/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular, firebase, typescript

Research direction

Reproduce the failure using the @angular/fire/auth imports and compare it with the working firebase/auth imports shown in the issue. Trace the authentication entry points and verify that setPersistence with browserLocalPersistence works through @angular/fire/auth without the TypeError.

Written by the indexing model from the issue text.

Description

Problem
The setPersistence method does not work when imported from @angular/fire/auth, leading to a TypeError. However, it works when imported from firebase/auth.

Error
When using the import from @angular/fire/auth, the following error is encountered:

ERROR TypeError: Class constructor _BrowserLocalPersistence cannot be invoked without 'new'
Code Example

  • Non-functional:
    import { setPersistence, browserLocalPersistence } from '@angular/fire/auth';
    await setPersistence(this.auth, browserLocalPersistence);

  • Functional:
    import { setPersistence, browserLocalPersistence } from 'firebase/auth';
    await setPersistence(this.auth, browserLocalPersistence);

Dominant language
TypeScript
Stars
7.8k
Forks
2.1k
Avg merge
2d 22h
Merged PRs (30d)
25

Getting set up

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 angular/angularfire

All issues in angular/angularfire

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.