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
Setting attribute values to undefined can save on storage and transmission costs, as the attribute names will not be encoded. However, this can complicate the semantics of clearing values vs. absent values.
🌐
W3Schools
w3schools.com › typescript › typescript_null.php
TypeScript Null & Undefined
Nullish coalescing is another JavaScript feature that also works well with TypeScript's null handling. It allows writing expressions that have a fallback specifically when dealing with null or undefined.
🌐
GitHub
github.com › microsoft › TypeScript › issues › 9653
Guidelines for choosing between `null` and `undefined` with `strictNullChecks` · Issue #9653 · microsoft/TypeScript
June 10, 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
🌐
TypeScript
typescriptlang.org › docs › handbook › release-notes › typescript-2-0.html
TypeScript: Documentation - TypeScript 2.0
In practical terms, strict null checking mode requires that all files in a compilation are null- and undefined-aware. TypeScript 2.0 implements a control flow-based type analysis for local variables and parameters.
🌐
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
🌐
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.
Find elsewhere
🌐
Tektutorialshub
tektutorialshub.com › home › typescript › null vs undefined in typescript
Null Vs Undefined in TypeScript - Tektutorialshub
March 15, 2023 - But TypeScript never assigns null to any variable. We have to assign Null to variable to make it null. The following example declares the variable foo. We have not given it any initial value. By default, it gets the value undefined.
🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_null_vs_undefined.htm
TypeScript - null vs. undefined
Developer's Best Practices · Questions ... Glossary · Who is Who · Previous · Quiz · Next · In TypeScript, 'undefined' denotes that a variable has been declared but has not been assigned any value....
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › how-to-check-null-and-undefined-in-typescript
How to check null and undefined in TypeScript ? - GeeksforGeeks
July 23, 2025 - In this approach, we utilize the optional chaining (?.) and nullish coalescing (??) operators to check if a variable is null or undefined. These operators provide a concise and readable way to handle null and undefined values in TypeScript.
🌐
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?
Use null when you want to explicitly indicate that a value is absent. Avoid unnecessary undefined assignments. Enable strictNullChecks in TypeScript to catch potential issues.
🌐
DEV Community
dev.to › johannesjo › how-do-you-deal-with-null-vs-undefined-4899
How do you deal with null vs undefined? - DEV Community
July 5, 2020 - When we write TypeScript apps, we tend to prefer using neither null nor undefined. We use null objects : let’s say you have a Customer to display. We use a const NoCustomer of same type to underline that there is no customer selected/in state ...
🌐
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?
Use != null only when you explicitly want to check for both null and undefined. ... If offerPrice might explicitly be null, you should use offerPrice != null to handle both cases. Take your presentation to the next level. ... Put your face and name on your screen. ... Show keypresses on your screen. ... Your to-dos on your menu bar. ... Fill forms using your right-click menu. ... Preview your Mac app icons. ... question typescript javascript July 17, 2024 Difference between ??
🌐
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.
🌐
Webdevtutor
webdevtutor.net › blog › typescript-null-vs-undefined-best-practice
TypeScript Null vs Undefined: Best Practice
if (myVar !== null && myVar !== undefined) { // Safe to access properties or methods } Enable Strict Null Checks: In your tsconfig.json file, set "strictNullChecks": true to enable strict null checks. This option helps catch potential null or undefined errors during compilation.
🌐
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.