DEV Community

Discussion on: Vue, guard routes with Firebase Authentication

gautemeekolsen profile image
Gaute Meek Olsen Author

Usually, TS won't let you add a method to another object without something additional.

But maybe you can just assign the method to a new variable instead:

const getCurrentUser = () => {
    return new Promise((resolve, reject) => {
        const unsubscribe = firebase.auth().onAuthStateChanged(user => {
        }, reject);
Enter fullscreen mode Exit fullscreen mode
chromaticranger profile image
Martin Stickley

I can confirm that this approach worked for me in TS. :-) Many thanks @gautemeekolsen for sharing this knowledge.