Erro "
Argument of type '(userName: any) => void' is not assignable to parameter of type '(value: any, index: number) => ObservableInput<{}>'. Type 'void' is not assignable to type 'ObservableInput<{}>' "
import { Injectable } from "@angular/core";
import { AbstractControl } from "@angular/forms";
import { SignUpService } from "./signup.service";
import { debounceTime, switchMap, map , first} from "rxjs/operators";
import { Observable } from "rxjs";
@Injectable({ providedIn: 'root'})
export class UserNotTakenValidatorService {
constructor(private signUpService: SignUpService){}
checkUserNameTaken(){
return (control: AbstractControl) => {
return control
.valueChanges
.pipe(debounceTime(300))
.pipe(switchMap(userName: => {
this.signUpService.checkUserNameTaken(userName);
}
))
.pipe(map(isTaken => isTaken ? { checkUserNameTaken: true}: null))
.pipe(first());
}
}
}