This post explains the differences very well. They are the same in TypeScript as in JavaScript.

As for what you should use: You may define that on your own. You may use either, just be aware of the differences and it might make sense to be consistent.

The TypeScript coding style guide for the TypeScript source code (not an official "how to use TypeScript" guide) states that you should always use undefined and not null: Typescript Project Styleguide.

Answer from Spitzbueb on Stack Overflow
🌐
Reddit
reddit.com › r/typescript › undefined vs null
r/typescript on Reddit: Undefined vs null
February 27, 2023 -

Since switching to TypeScript I have been using a lot of optional properties, for example:

type store = {
  currentUserId?: string
}

function logout () {
  store.currentUserId = undefined
}

However my coworkers and I have been discussing whether null is a more appropriate type instead of undefined, like this:

type store = {
  currentUserId: string | null
}

function logout () {
  store.currentUserId = null
}

It seems like the use of undefined in TypeScript differs slightly from in Javascript.

Do you guys/girls use undefined or null more often? And, which of the examples above do you think is better?

Discussions

Undefined vs null : typescript
🌐 r/typescript
NULL vs undefined as explicit return typ
Nobody seems to agree on this. In my opinion having two values for null is dumb. I’d like to only have one value that represents a null value. Since it’s not possible to avoid using undefined, I avoid using null instead. There’s an eslint rule that you can use that will give an error every time null is used. That’s the best solution IMO More on reddit.com
🌐 r/typescript
11
8
July 13, 2023
Undefined vs null
One reason to favor undefined over null is how javascript handle default values: const withDefault = (a = true) => { console.log(a); }; withDefault(); // logs true withDefault(undefined); // logs true withDefault(null); // logs null More on reddit.com
🌐 r/typescript
51
46
February 27, 2023
Null v undefined in type definitions for SQL tables
Not strictly related to SQL tables, but in typescript in general, I prefer to use null to state I explicitly set that value as empty, undefined is for values that we may not have considered (like access to non existing object properties). I only use undefined for lazy relations between tables. More on reddit.com
🌐 r/typescript
9
8
November 7, 2024
🌐
DEV Community
dev.to › sduduzog › null-vs-undefined-what-to-choose-what-to-use-11g
null vs undefined? What to choose? What to use? - DEV Community
August 23, 2023 - When a javascript object is being serialized, all undefined properties are discarded, remember 'undefined' means a property is yet to be assigned a value. But null on the other hand is known by JSON as its a valid JSON data type
🌐
Medium
medium.com › @o_o_o › null-vs-undefined-can-i-use-only-one-a3b7db5468f2
null vs. undefined: Can I use only one? | by OOO | Medium
March 29, 2022 - In older browsers, it was possible to overwrite undefined because it is not a reserved word unlike null. So it leads to side effect if you do this: But in modern browsers (JavaScript 1.8.5 / Firefox 4+), undefined is a non-configurable, non-writable property, per the ECMAScript 5 specification. So it’s no longer a problem if you’re using “modern browser”. And there’re already some guys doing it: Typescript team only uses undefined and Douglas Crockford stopped using null.
🌐
GitBook
basarat.gitbook.io › typescript › recap › null-undefined
Null vs. Undefined | TypeScript Deep Dive
August 18, 2020 - Something hasn't been initialized : undefined. Something is currently unavailable: null.
🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_null_vs_undefined.htm
TypeScript - null vs. undefined
In TypeScript, 'undefined' denotes that a variable has been declared but has not been assigned any value. On the other hand, 'null' refers to a non-existent object which is basically 'empty' or 'nothing'.
🌐
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.
Find elsewhere
🌐
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.
🌐
Mikevosseller
blog.mikevosseller.com › 2022 › 10 › 03 › when-to-use-null-vs-undefined-with-optional-parameters-in-typescript.html
When to use null vs undefined with optional parameters in TypeScript | mpv’s little blog
October 4, 2022 - An undefined value may indicate the value should not be updated. If an argument isn’t needed at every call site I’ll make it optional OR give it a default value if there is one that makes sense. If an argument should accept null then I’ll allow null by adding | null to its type.
🌐
DEV Community
dev.to › typescripttv › what-is-the-difference-between-null-and-undefined-5h76
What is the difference between null and undefined? - DEV Community
March 12, 2023 - The convention in TypeScript is that undefined values have not been defined yet, whereas null values indicate intentional absence of a value.
🌐
Hacker News
news.ycombinator.com › item
The difference between null and undefined in JavaScript is something I wished ha... | Hacker News
October 13, 2021 - I have only seen null vs undefined lead to 2 things in my experience: mistakes and bikeshedding · The "billon dollar mistake" as described by Tony Hoare was not nulls per se
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › how-to-check-null-and-undefined-in-typescript
How to check null and undefined in TypeScript ? - GeeksforGeeks
July 23, 2025 - Null refers to a value that is either empty or doesn't exist. null means no value. To make a variable null we must assign null value to it as by default in typescript unassigned values are termed undefined.
🌐
Rampatra
blog.rampatra.com › null-vs-undefined-in-typescript-or-javascript-how-to-check-for-both-at-once
!== null vs !== undefined in Typescript or Javascript, how to check for both at once?
November 14, 2024 - You want to check for both null and undefined together, since null and undefined are considered equal in loose equality (==).
🌐
GitHub
yellowduck.be › posts › null-vs-undefined-in-typescript-and-javascript-whats-the-difference
🐥 Null vs. Undefined in TypeScript and JavaScript: what's the difference?
March 18, 2025 - Understanding null and undefined helps in writing clearer and more predictable code. While undefined typically signifies an uninitialized value, null is used for explicitly clearing or indicating the absence of a value.
🌐
Tektutorialshub
tektutorialshub.com › home › typescript › null vs undefined in typescript
Null Vs Undefined in TypeScript - Tektutorialshub
March 15, 2023 - It means that a variable has been declared but has not yet been assigned a value. The value null indicates that you know that the field does not have a value. It is an intentional absence of value.
🌐
Schibsted-vend
schibsted-vend.pl › home › javascript dilemma: null or undefined
JavaScript Dilemma: null or undefined - Schibsted and Vend Polska
May 26, 2022 - In this example, we could make use of the “optional” functionality that TypeScript provides and replace all the “| null” with “?”. The more types you create, the more nulls you have to type. Moreover, TypesScript has the utility type Partial<T> that allows for making all of the properties in a specific type optional and that provides another advantage to undefined.
🌐
Quora
quora.com › What-is-the-difference-between-undefined-null-and-false
What is the difference between 'undefined', 'null', and 'false'? - Quora
Answer: In most programming languages there is undefined, null, and false is a value given to a Boolean variable. When it comes to any variable null means that it wasn’t assigned any value. And undefined it means that the variable wasn’t even declared(for example trying to print a variable ...
🌐
SheCodes
shecodes.io › athena › 2227-what-is-the-difference-between-null-and-undefined-in-javascript
[JavaScript] - What is the Difference Between Null and Undefined in JavaScript?
Learn what is the difference between null and undefined in JavaScript and how to distinguish between them. Check how to use a typeof operator.