The typescript compiler performs strict null checks, which means you can't pass a string | undefined variable into a method that expects a string.

To fix this you have to perform an explicit check for undefined before calling luminaireReplaceLuminaire().

In your example:

private selectedSerialForReplace(): string | undefined {
    return this.selectedSerials.pop();
}

luminaireReplaceLuminaire(params: {  "serial": string; "newserial": string; }, options?: any): FetchArgs {
    ............
}

const serial = this.selectedSerialForReplace();
if(serial !== undefined) {
    luminaireReplaceLuminaire({serial, newserial: response.output});
}
Answer from Acevail on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-string-method
JavaScript String() Method - GeeksforGeeks
August 5, 2025 - The String() method in JavaScript is a built-in function that converts any given value to its string representation. Whether the value is a number, boolean, object, or even null or undefined, the String() method ensures that the value is returned ...
Discussions

Declaring types as String | null | undefined
Well... this is not a question of preference but of business requirements or technical limitations. This is nothing you just decide to go with or not. I.e. in many contexts, empty strings and undefined/null strings are different in case you thought about replacing all undefined strings with empty strings. This whole null vs undefined discussion is on another level, though. Usually, I try to avoid null unless there are specific requirements that make it mandatory. One example is a partial update through some PATCH endpoint that is supposed to delete a field of the target entity. Here null can indicate deletion. More on reddit.com
🌐 r/typescript
11
0
June 23, 2025
Dumb noob question: Why is undefined in quotes?
I’m just watching the 3-hr JS video that FCC has up on YouTube. Why is undefined in quotation marks? Doesn’t that mean it’s looking for a string containing the word “undefined”? From what I learned, quotes around things turns them into strings. I can’t see how undefined would be ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
18
0
January 18, 2022
String.Format returning "undefined"
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. ... Results: This test is nice for undefined!!! More on github.com
🌐 github.com
4
June 6, 2017
How do I check for an empty/undefined/null string in JavaScript? - Stack Overflow
== operator is not strict. So if str == "", str can be null, undefined, false, 0, [], etc.. 2019-09-11T07:05:41.82Z+00:00 ... You can easily add it to native String object in JavaScript and reuse it over and over... More on stackoverflow.com
🌐 stackoverflow.com
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › undefined
undefined - JavaScript | MDN
The undefined global property represents the primitive value undefined. It is one of JavaScript's primitive types.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Dumb noob question: Why is undefined in quotes? - JavaScript - The freeCodeCamp Forum
January 18, 2022 - I’m just watching the 3-hr JS video that FCC has up on YouTube. Why is undefined in quotation marks? Doesn’t that mean it’s looking for a string containing the word “undefined”? From what I learned, quotes around things turns them into strings. I can’t see how undefined would be a string, yet it is typed out like it is a string.
🌐
Medium
medium.com › @yi_yuan › understanding-null-undefined-and-empty-strings-in-javascript-a07959084d
Understanding Null, Undefined, and Empty Strings in JavaScript | by Yi Yuan | Medium
January 8, 2023 - Also, please note that all functions return undefined by default unless it’s been decided to return a specific value instead. An empty string is a string that has nothing inside it. It’s like a word that has no letters.
🌐
TypeScript TV
typescript.tv › hands-on › fixing-typescript-error-type-undefined-is-not-assignable-to-type-string
Fixing TypeScript Error: Type undefined is not assignable to type string
July 3, 2024 - To fix error TS2345, you have several approaches, each with its advantages and considerations: JavaScript and TypeScript implicitly convert undefined to the string "undefined" when concatenated with a string.
Find elsewhere
🌐
Medium
medium.com › dailyjs › 5-ways-to-convert-a-value-to-string-in-javascript-6b334b2fc778
5 Ways to Convert a Value to String in JavaScript | by Samantha Ming | DailyJS | Medium
May 27, 2019 - Here are the variables we’re going to test these against: const string = "hello"; const number = 123; const boolean = true; const array = [1, "2", 3]; const object = {one: 1 }; const symbolValue = Symbol('123'); const undefinedValue = undefined; const nullValue = null; string + ''; // 'hello' number + ''; // '123' boolean + ''; // 'true' array + ''; //… · 110K followers · ·Last published Jul 12, 2022 · JavaScript news and opinion.
🌐
Sentry
sentry.io › sentry answers › javascript › how do i check for an empty/undefined/null string in javascript?
How do I Check for an Empty/Undefined/Null String in JavaScript? | Sentry
The first operand uses the typeof operator to check if the argument value is a string. If the value is a string, leading and trailing white space and line terminator strings are removed using the trim() method. This logical && operator expression returns true if a string is empty or consists of white space and line terminator strings only. Youtube How Sentry.io saved me from disaster (opens in a new tab) Resources Improve Web Browser Performance - Find the JavaScript code causing slowdowns (opens in a new tab)
🌐
GitHub
github.com › andrewplummer › Sugar › issues › 593
String.Format returning "undefined" · Issue #593 · andrewplummer/Sugar
June 6, 2017 - Exemple: "This {first} is nice for {second}!!!".format({first: "test"}); Results: This test is nice for undefined!!! Expect result: This test is nice for !!! The problem: If the {second} is not provided, it gets replaced by the literal u...
Author   cacothi
🌐
DhiWise
dhiwise.com › post › understand-error-type-string-undefined-is-not-assignable
Type String Undefined Is Not Assignable: Resolve The Error
October 17, 2024 - How can I resolve the "type string undefined is not assignable to type string" error? What is the nullish coalescing operator in TypeScript? How do I check if a variable is undefined in TypeScript? What are the best practices for avoiding TypeScript type errors? ... This powerful superset of JavaScript takes coding to the next level by introducing static types, allowing developers to define the exact type of variables, parameters, and function return values.
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Data_structures
JavaScript data types and data structures - JavaScript | MDN
January 21, 2025 - All data types, except Null, Undefined, and Symbol, have their respective coercion process. See string coercion, boolean coercion, and object coercion for more details. As you may have noticed, there are three distinct paths through which objects may be converted to primitives:
🌐
Medium
medium.com › @codehome › how-do-i-check-for-an-empty-undefined-null-string-in-javascript-b4a9507742b4
How do I check for an empty/undefined/null string in JavaScript? | by Programise | Medium
January 16, 2023 - let str = ""; if(str.length === 0) { console.log("String is empty"); } 2. To check for an undefined variable, you can use the typeof operator.
🌐
Linux Hint
linuxhint.com › check-empty-undefined-null-string-javascript
How to Check Empty/Undefined/Null String in JavaScript?
August 14, 2022 - The equality “===” operator, length property, and Boolean method are utilized to check the empty/undefined/null string in JavaScript.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Object › toString
Object.prototype.toString() - JavaScript | MDN
July 10, 2025 - Object.prototype.toString() invoked on null and undefined returns [object Null] and [object Undefined], respectively. You can create a function to be called in place of the default toString() method. The toString() function you create should return a string value.
🌐
GitBook
basarat.gitbook.io › typescript › recap › null-undefined
Null vs. Undefined | TypeScript Deep Dive
August 18, 2020 - JavaScript (and by extension TypeScript) has two bottom types : null and undefined. They are intended to mean different things:
🌐
Folkstalk
folkstalk.com › home › 2022 › september
Js Type-Check Undefined Or String With Code Examples
September 17, 2022 - We investigated a wide range of use cases in order to find a solution to the Js Type-Check Undefined Or String problem. Answer: Use the equality operator ( == ) In JavaScript if a variable has been declared, but has not been assigned a value, ...