I want to assign a variable, which is string | undefined, to a string variable, as you see here:
private selectedSerialForReplace(): string | undefined {
return this.selectedSerials.pop();
}
luminaireReplaceLuminaire(params: { "serial": string; "newserial": string; }, options?: any): FetchArgs {
............
}
luminaireReplaceLuminaire({serial: this.selectedSerialForReplace(), newserial: response.output});
I get this error:
Argument of type '{ serial: string | undefined; newserial: any; }' is not assignable to parameter of type '{ "serial": string; "newserial": string; }'
I cannot change selectedSerialForReplace() function to return anything else. Could you please help me?
luminaireReplaceLuminaire
? Is it supposed to accept undefined "serial" parameters? – Mothyconst [username, setUsername] = useState<string | null>(null);
– Raynell