You can simply use typeof. It will check undefined, null, 0 and "" also.

if(typeof RetailPrice!='undefined' && RetailPrice){
   return this.RetailPrice;
}
Answer from Unknown on Stack Overflow
🌐
W3Schools
w3schools.com › typescript › typescript_null.php
TypeScript Null & Undefined
let value: string | undefined | null = null; value = 'hello'; value = undefined; Try it Yourself » · When strictNullChecks is enabled, TypeScript requires values to be set unless undefined is explicitly added to the type.
🌐
TypeScript
typescriptlang.org › play › typescript › type-primitives › nullable-types.ts.html
TypeScript: Playground Example - Nullable Types
If text returned as undefined then the result is the same as though it was not there. This might feel a bit superficial, but when converted into a JSON string, if text was an undefined, it would not be included in the string equivalent. Strict Null Types Before TypeScript 2.0 undefined and ...
🌐
Bobby Hadz
bobbyhadz.com › blog › typescript-type-null-is-not-assignable-to-type-string
Type 'string or null' is not assignable to type string (TS) | bobbyhadz
When you use this approach, you basically tell TypeScript that this value will never be null or undefined. This is very similar to a type assertion and should only be used when you're absolutely sure that the value is of the expected type. ... Copied!interface Employee { id: number; name: string | null; } const emp: Employee = { id: 1, name: 'Bobby Hadz', }; const name: string = emp.name as string; // 👈️ type assertion console.log(name); // 👉️ "Bobby Hadz"
🌐
Tektutorialshub
tektutorialshub.com › home › typescript › null in typescript
Null in TypeScript - Tektutorialshub
March 15, 2023 - To do that we assign the literal null to the variable ... TypeScript also has an undefined value and it means the value is not assigned or we do not know its value. Take an example of the following person function which returns the person object.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › explain-the-concept-of-null-and-its-uses-in-typescript
Explain the concept of null and its uses in TypeScript - GeeksforGeeks
March 2, 2022 - In TypeScript, a data type defines the kind of values a variable can hold, ensuring type safety and enhancing code clarity.Primitive Types: Basic types like number, string, boolean, null, undefined, and symbol.Object Types: Complex structures including arrays, classes, interfaces, and functions.Prim
🌐
TypeScript
typescriptlang.org › docs › handbook › release-notes › typescript-2-0.html
TypeScript: Documentation - TypeScript 2.0
TypeScript has two special types, Null and Undefined, that have the values null and undefined respectively.
🌐
GitBook
basarat.gitbook.io › typescript › recap › null-undefined
Null vs. Undefined | TypeScript Deep Dive
August 18, 2020 - Recommend == null to check for both undefined or null. You generally don't want to make a distinction between the two. ... function foo(arg: string | null | undefined) { if (arg != null) { // arg must be a string as `!=` rules out both null and undefined.
🌐
Medium
medium.com › @enayetflweb › understanding-nullable-unknown-and-never-types-in-typescript-b183fb792d2d
Understanding Nullable, Unknown, and Never Types in TypeScript | by Md Enayetur Rahman | Medium
May 5, 2024 - Here, if we pass a string to searchName, it works fine. However, if we ever want to pass null to this function, TypeScript will complain because null isn’t a valid type for the parameter value.
🌐
C# Corner
c-sharpcorner.com › UploadFile › c63ec5 › string-in-typescript
String in TypeScript
October 9, 2019 - Here I am defining two ways to create an empty string. The code is given below: ... A null string references the one and only value of the Null type. It is not possible to directly reference the Null type itself.
🌐
Medium
greg-pabian.medium.com › nullability-in-typescript-60be8c5a6d87
Nullability in TypeScript - Greg Pabian - Medium
May 17, 2019 - Type A is trivial, as it allows for property x to hold a value that is either a string or a null.
🌐
Pinter Computing
pinter.org › home › knowledge base
Type ‘null’ is not assignable to type ‘string’ – Pinter Computing
This can be necessary when we want to set the value of a database column to “null”. To make a string type attribute nullable, add ” | null ” to the type definition:
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › how-to-check-null-and-undefined-in-typescript
How to check null and undefined in TypeScript ? - GeeksforGeeks
July 23, 2025 - These operators provide a concise and readable way to handle null and undefined values in TypeScript. Example: Below is an example demonstrating the use of optional chaining and nullish coalescing operators to check for null or undefined values. We declare variables that can be either undefined, null, or assigned a value. let undefinedVar: string | undefined; let nullVar: string | null = null; let assignedVar: string | null | undefined = "Hello, World!"; JavaScript ·
🌐
Medium
medium.com › @AlexanderObregon › where-null-and-undefined-are-watched-in-typescript-647ecabe346f
Where Null and Undefined Are Watched in TypeScript | Medium
July 1, 2025 - JavaScript makes a distinction between null and undefined, and TypeScript reflects that same split in its type system. undefined shows up when a variable hasn’t been set or a function doesn’t return anything. null is something you assign on purpose to mean there’s no value. let output: string console.log(output) // undefined let message: string | null = null // value cleared on purpose
🌐
Envato Tuts+
code.tutsplus.com › home › coding fundamentals
TypeScript for Beginners, Part 2: Basic Data Types | Envato Tuts+
January 28, 2022 - Just as in JavaScript, the null data type in TypeScript can have only one valid value: null. A null variable cannot contain other data types like number and string.
🌐
typescriptlang.org
typescriptlang.org › docs › handbook › 2 › everyday-types.html
TypeScript: Documentation - Everyday Types
There won’t be an exception or null generated if the type assertion is wrong. TypeScript only allows type assertions which convert to a more specific or less specific version of a type. This rule prevents “impossible” coercions like: ... x = "hello" as number;Conversion of type 'string' to ...
🌐
Luis Llamas
luisllamas.es › home › courses › typescript programming course
Use of Null and Undefined in TypeScript
December 6, 2024 - You can define types that include null and undefined. let name: string | null = "Luis"; name = null; let age: number | undefined; age = 25; age = undefined;