I want to assign a variable, which is string | undefined, to a string variable, as you see here:
private selectedSerialForReplace(): string | undefined {
If you are sure that serial could not be undefined you can use the ! post-fix operator
undefined
luminaireReplaceLuminaire({serial: this.selectedSerialForReplace()!, newserial: response.output});