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?

🌐
GitBook
basarat.gitbook.io › typescript › recap › null-undefined
Null vs. Undefined | TypeScript Deep Dive
Something hasn't been initialized : undefined. Something is currently unavailable: null.
🌐
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.
🌐
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
🌐
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.
🌐
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.
🌐
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'.
Find elsewhere
🌐
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.
🌐
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.
🌐
GitHub
github.com › microsoft › TypeScript › issues › 9653
Guidelines for choosing between `null` and `undefined` with `strictNullChecks` · Issue #9653 · microsoft/TypeScript
June 11, 2016 - Whenever you want to make a type optional you have to choose what value to use for the missing values: undefined: Has the benefit that is already there when you don't write anything. lib.d.ts contains 12 references of | undefined. null: ...
Published   Jul 12, 2016
🌐
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?
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.
🌐
HowToDoInJava
howtodoinjava.com › home › typescript › difference between undefined and null
JavaScript - Difference between undefined and null
September 22, 2021 - In simple words, when we do not assign any value to a variable, the JavaScript engine treats it as undefined. The null value is assigned by the programmer to indicate that the variable has nothing inside of it, but intends to have a value later ...
🌐
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.
🌐
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.
🌐
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.
🌐
Luis Llamas
luisllamas.es › inicio › cursos › curso typescript
Use of Null and Undefined in TypeScript
December 6, 2024 - Undefined: It is a value that indicates a variable has been declared but not initialized. Null: It is a value that is explicitly assigned to a variable to indicate the intentional absence of a value.
🌐
Zipy
zipy.ai › blog › debug-typescript-null-or-undefined-value-errors
Solving Typescript Null & Undefined Errors: Expert Tips
February 28, 2024 - This design choice is inherited from JavaScript, providing flexibility in indicating the absence of a value (null) versus an uninitialized variable (undefined). ... Zipy offers proactive error monitoring and session replay capabilities, allowing ...
🌐
Javatpoint
javatpoint.com › null-vs-undefined
Difference Between Null and Undefined - javatpoint
Difference Between Null and Undefined with typescript tutorial, typescript introduction, versions, typescript and javascript, features, components, installation, typescript types, etc.