I am trying to convert an Observable into a Signal to be returned from the login function.
login(username: string, password: string): Signal<LoginResponse> {
const sourceObservable: Observable<LoginResponse> =
this.http.post<LoginResponse>(this.apiUrl + '/login', {username, password})
let lrp: LoginResponse = LoginResponse.withStatus(ResponseStatus.PENDING)
return toSignal<LoginResponse>(sourceObservable, {requireSync: true, initialValue: lrp,}
)
}
In the return statement I use toSignal() that takes a ToSignalOptions object with requireSync set to true, and an initial value. However the compiler is complaining at me that there are no overload matches, because it is expecting an initialValue of type undefined, whereas I am providing a type of LoginResponse. It should be LoginResponse, but the analyser does not like that.
Have I done something wrong I am overlooking?

Please remove
requireSyncfrom theToSignalOptionsinitialValueis allowed only whenrequireSyncis falsy