I'm having the following error:
error TS2339: Property 'includes' does not exist on type '{}'.
when trying to check if a username is taken or not. (It's perfectly working when I comment this error, then start with ng serve and then uncomment it but i cant launch my serve with the error, that's why I used this trick)
Service:
isUsernameAvailable(){
const users = [];
return new Promise(function(resolve, reject){
firebase.database().ref('users').orderByKey().once('value').then(snapshot => {
snapshot.forEach(childSnapshot => {
if(childSnapshot.val().username){
users.push(childSnapshot.val().username);
}
})
resolve(users);
})
});
}
Component:
async checkUsername(){
const username=this.signupForm.get('username').value;
const usernames =await this.authService.isUsernameAvailable();
if(usernames.includes(username)){
this.usernameAvailable=false;
}
else {
this.usernameAvailable=true;
}
}
I saw some people having a similar error with type String[] and problem was in tsconfig with es2017, but I already have it:
"lib": [
"es2017",
"dom"
]
Where am I wrong ?