All fields in JavaScript (and in TypeScript) can have the value null or undefined.

You can make the field optional which is different from nullable.

interface Employee1 {
    name: string;
    salary: number;
}

var a: Employee1 = { name: 'Bob', salary: 40000 }; // OK
var b: Employee1 = { name: 'Bob' }; // Not OK, you must have 'salary'
var c: Employee1 = { name: 'Bob', salary: undefined }; // OK
var d: Employee1 = { name: null, salary: undefined }; // OK

// OK
class SomeEmployeeA implements Employee1 {
    public name = 'Bob';
    public salary = 40000;
}

// Not OK: Must have 'salary'
class SomeEmployeeB implements Employee1 {
    public name: string;
}

Compare with:

interface Employee2 {
    name: string;
    salary?: number;
}

var a: Employee2 = { name: 'Bob', salary: 40000 }; // OK
var b: Employee2 = { name: 'Bob' }; // OK
var c: Employee2 = { name: 'Bob', salary: undefined }; // OK
var d: Employee2 = { name: null, salary: 'bob' }; // Not OK, salary must be a number

// OK, but doesn't make too much sense
class SomeEmployeeA implements Employee2 {
    public name = 'Bob';
}
Answer from Ryan Cavanaugh 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 โ€บ 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. Previously it was not possible to explicitly name these types, but null and undefined may now be used as type names regardless of type checking mode.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ typescript โ€บ typescript-null-and-undefined-type
TypeScript null and undefined Type - GeeksforGeeks
April 28, 2025 - ... Itโ€™s commonly used to represent missing function arguments or uninitialized object properties. ... When strictNullChecks is turned off (which is the default behavior), TypeScript is more permissive with null and undefined, and they are ...
๐ŸŒ
Tektutorialshub
tektutorialshub.com โ€บ home โ€บ typescript โ€บ null in typescript
Null in TypeScript - Tektutorialshub
March 15, 2023 - The null in TypeScript is a special value & also a primitive data type. The value null represents the intentional absence of any object value.
๐ŸŒ
Medium
greg-pabian.medium.com โ€บ nullability-in-typescript-60be8c5a6d87
Nullability in TypeScript - Greg Pabian - Medium
May 17, 2019 - If strictNullCheck configuration parameter (in tsconfig.json) is set to false, then null and undefined types are always a subtype of every other defined type, which results in the following statement being valid: ... This mode is tremendously beneficial for projects that have been written in JavaScript and are being migrated to TypeScript, but it doesnโ€™t protect us from nullability errors.
Find elsewhere
๐ŸŒ
Reddit
reddit.com โ€บ r/typescript โ€บ is it better to use "nullable" or "t | null"
r/typescript on Reddit: Is it better to use "Nullable<T>" or "T | null"
February 28, 2023 -

I have had this dilemma for some time now while making an app using Create-React-App with Typescript. My colleague came up with this idea and i have no idea which is better to use. I don't think one is better for performance but i would like to know which is more used in general.

Both variations work flawlessly but i would like to know which one you prefer more.

๐ŸŒ
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.
๐ŸŒ
EDUCBA
educba.com โ€บ home โ€บ software development โ€บ software development tutorials โ€บ typescript tutorial โ€บ typescript nullable
TypeScript Nullable | Rules and Regulations for Nullable with Examples
April 11, 2023 - TypeScript Nullable is a special type null that has the value null. TypeScript Null is much like void, i.e. not useful on its own. By default, null is a subtype of all other subtypes which means a user can assign null to any of the data types ...
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
๐ŸŒ
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 null were effectively ignored in the type system.
๐ŸŒ
OverCtrl
blog.overctrl.com โ€บ typescript-nullable-types-explained-your-comprehensive-guide-with-code-examples
TypeScript Nullable Types Explained: Your Comprehensive Guide with Code Examples
June 26, 2026 - This article provides an in-depth ... with practical examples. A nullable type refers to a type that can either hold a value of a specific type or be null or undefined....
๐ŸŒ
Mistermicheels
learning-notes.mistermicheels.com โ€บ nullable types and optional parameters/properties
Nullable types and optional parameters/properties (TypeScript) | learning-notes
January 31, 2022 - Operator ! that allows to let TypeScript know you are sure that a certain value is not null or undefined (useful in situations where the code is too complex for TypeScript to figure this out by itself) ... function test(str: string | null | undefined) { const ensureStringDefined = function () { if (str === null || str === undefined) { str = "test"; } } ensureStringDefined(); console.log(str.toUpperCase()); // error console.log(str!.toUpperCase()); // ok } If --strictNullChecks is enabled, making a parameter optional automatically adds | undefined to its type
๐ŸŒ
Theclientside
theclientside.net โ€บ nullable types
Nullable Types in TypeScript (Live Playground) | TheClientSide.net
In TypeScript, nullable types are types that can have a value of null in addition to their usual values.
๐ŸŒ
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 - Null refers to a value that is either empty or a value that doesn't exist. It's on purpose that there's no value here. TypeScript does not make a variable null by default.
๐ŸŒ
Tektutorialshub
tektutorialshub.com โ€บ home โ€บ typescript โ€บ null vs undefined in typescript
Null Vs Undefined in TypeScript - Tektutorialshub
March 15, 2023 - The value null indicates that you know that the field does not have a value. It is an intentional absence of value. Whenever we declare a variable without initializing it with a value, TypeScript initializes it as undefined.
๐ŸŒ
Medium
medium.com โ€บ @gabrielairiart.gi โ€บ the-power-of-nonnullable-t-in-typescript-9cf156beb8da
The Power of NonNullable<T> in TypeScript | by Gabriela Iriart | Medium
March 28, 2024 - The NonNullable<T> utility type ... manner. When applied to a type, NonNullable<T> creates a new type by removing null and undefined from the set of possible values that type could take....
๐ŸŒ
Hyperskill
hyperskill.org โ€บ university โ€บ typescript โ€บ typescript-null
TypeScript Null
August 23, 2024 - TypeScript treats null and undefined as distinct types. By default, when strictNullChecks is enabled, null and undefined can only be assigned to their respective types. Null can be assigned to variables of type null or any, while undefined can be assigned to variables of type undefined or any.
๐ŸŒ
Marius Schulz
mariusschulz.com โ€บ blog โ€บ non-nullable-types-in-typescript
Non-Nullable Types in TypeScript โ€” Marius Schulz
September 28, 2016 - Prior to TypeScript 2.0, the type checker considered null and undefined to be valid values of every type. Basically, null and undefined could be assigned to anything.