apresentou o seguinte erro:
ERROR in src/app/home/signup/user-not-taken.validator.service.ts(18,33): error TS2345: 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<{}>'.
Segue o código:
import { Injectable } from '@angular/core';
import { AbstractControl } from '@angular/forms';
import { SignUpService } from "./signup.service";
import { debounceTime, switchMap, map } from 'rxjs/operators';
@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 ? { userNameTaken: true} : null))
}
}
}