I'm puzzled about the error I'm encountering in TypeScript: "Argument of type 'number | null' is not assignable to parameter of type 'number'", even though I have already checked if my variable is not null.
Is there any other solution apart from double-checking if my variable isn't null after subscribing?
Here's an example:
if (this.myVariable) {
this.dialogService
.openConfirmDialog('TITLE', 'CONTENT')
.afterClosed()
.pipe(take(1))
.subscribe((userChoice: boolean) => {
if(userChoice){
this.restFacadeService
.archiveBook(this.myVariable) //This is where the error occurs
.subscribe(() => {
this.createCustomBook();
})
}
});
} else { this.createCustomBook(); }