Yes. As of TypeScript 3.7 (released on November 5, 2019), this feature is supported and is called Optional Chaining:

At its core, optional chaining lets us write code where TypeScript can immediately stop running some expressions if we run into a null or undefined. The star of the show in optional chaining is the new ?. operator for optional property accesses.

Refer to the TypeScript 3.7 release notes for more details.


Prior to version 3.7, this was not supported in TypeScript, although it was requested as early as Issue #16 on the TypeScript repo (dating back to 2014).

As far as what to call this operator, there doesn't appear to be a consensus. In addition to "optional chaining" (which is also what it's called in JavaScript and Swift), there are a couple of other examples:

  • CoffeeScript refers to it as the existential operator (specifically, the "accessor variant" of the existential operator):

The accessor variant of the existential operator ?. can be used to soak up null references in a chain of properties. Use it instead of the dot accessor . in cases where the base value may be null or undefined.

  • C# calls this a null-conditional operator.

a null-conditional operator applies a member access, ?., or element access, ?[], operation to its operand only if that operand evaluates to non-null; otherwise, it returns null.

  • Kotlin refers to it as the safe call operator.

There are probably lots of other examples, too.

Answer from Donut on Stack Overflow
Top answer
1 of 15
432

Yes. As of TypeScript 3.7 (released on November 5, 2019), this feature is supported and is called Optional Chaining:

At its core, optional chaining lets us write code where TypeScript can immediately stop running some expressions if we run into a null or undefined. The star of the show in optional chaining is the new ?. operator for optional property accesses.

Refer to the TypeScript 3.7 release notes for more details.


Prior to version 3.7, this was not supported in TypeScript, although it was requested as early as Issue #16 on the TypeScript repo (dating back to 2014).

As far as what to call this operator, there doesn't appear to be a consensus. In addition to "optional chaining" (which is also what it's called in JavaScript and Swift), there are a couple of other examples:

  • CoffeeScript refers to it as the existential operator (specifically, the "accessor variant" of the existential operator):

The accessor variant of the existential operator ?. can be used to soak up null references in a chain of properties. Use it instead of the dot accessor . in cases where the base value may be null or undefined.

  • C# calls this a null-conditional operator.

a null-conditional operator applies a member access, ?., or element access, ?[], operation to its operand only if that operand evaluates to non-null; otherwise, it returns null.

  • Kotlin refers to it as the safe call operator.

There are probably lots of other examples, too.

2 of 15
157

It is now possible, see answer of user "Donut".

Old answer: Standard JavaScript behaviour regarding boolean operators has something that may help. The boolean methods do not return true or false when comparing objects, but in case of OR the first value that is equal to true.

Not as nice as a single ?, but it works:

var thing = foo && foo.bar || null;

You can use as many && as you like:

var thing = foo && foo.bar && foo.bar.check && foo.bar.check.x || null;

Default values are also possible:

var name = person && person.name || "Unknown user";
🌐
Educative
educative.io › answers › how-to-use-a-question-mark-in-typescript-variables
How to use a question mark in TypeScript variables
The question mark in typescript can be used to mention that a variable is optional or to pre-check if a member variable is present for an object.
Discussions

New Nullish Coalescing (?? Double question mark ) Operator in Typescript & Javascript

It's very recent, it was moved to stage 4 (Finished) 5 months ago https://github.com/tc39/proposal-nullish-coalescing

More on reddit.com
🌐 r/javascript
6
4
May 12, 2019
is the question mark before accessing some property in typescript bad?
Can you share the code you are referring to? It'd help to clarify your question to get better answers. More on reddit.com
🌐 r/learnprogramming
8
1
December 20, 2022
What does the question mark in the context of this expression mean: array?.length
This is known as optional chaining. If array exists it will access the length property otherwise it will evaluate to undefined. This is used to prevent run time errors, 'Cannot read property length of undefined' More on reddit.com
🌐 r/learnjavascript
16
57
July 30, 2021
Use of the Exclamation Mark in TypeScript
But when working with TypeScript, the exclamation mark acts as a non-null assertion operator. This non-null assertion will remove null and undefined values. False. The position of where you use it will define what it does. In type script, You can still do: !false to get true. If we define a string-type variable as string | null, it means that the variable holds a string or null value. No. It doesn't. It means you're telling TypeScript that this is what it is supposed to contain. However, in the articles first code example, it already fucks this up: let stringWord: string | null This is the first line of code in the article, and in this case stringWord has the value of undefined which is neither a string or null. In TypeScript, the question mark is used to define an argument as optional. It is the same as specifying the type as undefined. It is similar to studentName: string | undefined. Okay, so it IS similar, but it is not the same and you should explain the differences - let me explain them instead. const myFunc = (thing: string | undefined) => console.log(thing); myFunc(); This won't work, because it expects an argument for that parameter to be passed in, it's just saying that, you NEED to pass in an argument, but the argument itself may be string or undefined (in a case where we may not know). On the contrary: const myFunc = (thing?: string) => console.log(thing); myFunc(); Will work, because it's marking the parameter as optional, not the actual argument as undefined. In the second case: myFunc(undefined); won't work, but it will in the first case, because in the second case you're saying "You can either pass in NO argument, or if you do it MUST be s tring" the std parameter is marked as an optional parameter, so we cannot safely access the property of std. It can be either a Student type or an undefined type. No, it can't be, as per my above clarification. If an argument is passed in, it still HAS to be a Student in this part of the article. The only case you would get an undefined error, is if you called the function without passing anything in, e.g. getName() More on reddit.com
🌐 r/learnjavascript
1
0
December 6, 2022
🌐
freeCodeCamp
freecodecamp.org › news › how-the-question-mark-works-in-javascript
How the Question Mark (?) Operator Works in JavaScript
February 3, 2021 - By Nishant Kumar The conditional or question mark operator, represented by a ?, is one of the most powerful features in JavaScript. The ? operator is used in conditional statements, and when paired with a :, can function as a compact alternative ...
🌐
Bobby Hadz
bobbyhadz.com › blog › typescript-question-mark-dot
What is the ?. operator (optional chaining) in TypeScript | bobbyhadz
February 26, 2024 - The question mark dot (?.) syntax is called optional chaining in TypeScript and is like using dot notation to access a nested property of an object, but instead of causing an error if the reference is nullish, it short-circuits returning undefined.
🌐
DEV Community
dev.to › danywalls › simplify-your-typescript-code-with-optional-chaining-and-nullish-coalescing-37on
Simplify Your Typescript Code with Optional Chaining and Nullish Coalescing - DEV Community
May 23, 2023 - The double question mark (??) checks if the left-hand side value is nullish (null or undefined) and provides the right-hand side value as the default if needed. Nullish coalescing ensures that we always have a valid jersey number, even if it's ...
🌐
Omarileon
omarileon.me › blog › typescript-double-question-mark
mari. | Demystifying TypeScript's Double Question Mark: Nullish Coalescing
January 25, 2024 - An introduction to the double question marks in TypeScript, aka the nullish coalescing operator.
🌐
Medium
medium.com › @teamcode20233 › understanding-double-question-mark-operator-in-typescript-be869f210fe6
Understanding Double Question Mark Operator (??) in TypeScript | by Teamcode | Medium
July 3, 2023 - When we use the double question mark operator (??) to assign a default value to displayName, it checks if name is null or undefined. Since name is null, the default value “Guest” is assigned to displayName.
🌐
GitConnected
levelup.gitconnected.com › when-to-use-the-question-mark-or-undefined-type-in-typescript-233e74ab436
When to use the question mark or undefined type in TypeScript | by Ian Spryn | Level Up Coding
January 17, 2023 - So what’s the difference? Simply put, the question mark means the attribute is optional. If you do not provide a value for the attribute, it will be undefined.
Find elsewhere
🌐
Tim Mousk
timmousk.com › blog › typescript-double-question-mark
How To Use The Double Question Mark Operator In TypeScript? – Tim Mouskhelichvili
March 6, 2023 - The nullish coalescing or double question mark operator provides a default value for a null or undefined variable. This feature exists in JavaScript and TypeScript (added in version 3.7).
🌐
Medium
medium.com › totally-typescript › what-does-the-question-mark-dot-mean-in-javascript-or-typescript-9d7d744f6077
What Does the ?. Question Mark Dot Mean in JavaScript or TypeScript? | by Dr. Derek Austin 🥳 | Totally TypeScript | Medium
May 16, 2023 - What Does the ?. Question Mark Dot Mean in JavaScript or TypeScript? Unraveling the mystery of the ?. optional chaining operator with practical examples Introduction: Optional Chaining in JS / TS …
🌐
Yeminyi
yeminyi.github.io › myblog › typescript › 2020 › 11 › 20 › question-mark-in-typescript.html
Why use Question mark and Exclamation mark in TypeScript | Amy’s blog
November 20, 2020 - The language feature is called Non-null assertion operator. when you add an exclamation mark after variable/property name, you’re telling to TypeScript that you’re certain that value is not null or undefined.
🌐
GeeksforGeeks
geeksforgeeks.org › typescript › why-use-question-mark-in-typescript-variable
Why use Question Mark in TypeScript Variable? - GeeksforGeeks
July 12, 2025 - The question mark in TypeScript is used to mark a variable as optional, allowing it to be omitted or set to undefined. This is commonly used in object properties and function parameters, enhancing flexibility by making variables non-mandatory.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Optional_chaining
Optional chaining (?.) - JavaScript | MDN
The optional chaining (?.) operator accesses an object's property or calls a function. If the object accessed or function called using this operator is undefined or null, the expression short circuits and evaluates to undefined instead of throwing an error.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › Conditional_operator
Conditional (ternary) operator - JavaScript | MDN
The conditional (ternary) operator is the only JavaScript operator that takes three operands: a condition followed by a question mark (?), then an expression to execute if the condition is truthy followed by a colon (:), and finally the expression to execute if the condition is falsy.
🌐
TypeScript
typescriptlang.org › docs › handbook › release-notes › typescript-3-7.html
TypeScript: Documentation - TypeScript 3.7
At its core, optional chaining lets us write code where TypeScript can immediately stop running some expressions if we run into a null or undefined. The star of the show in optional chaining is the new ?. operator for optional property accesses.
🌐
Built In
builtin.com › software-engineering-perspectives › javascript-question-mark-operator
JavaScript Question Mark (?) Operator Explained | Built In
July 17, 2025 - Summary: The JavaScript question mark operator, or ternary operator, offers a concise alternative to if...else statements. It evaluates a condition and returns one of two values, streamlining variable assignment but potentially reducing code ...
🌐
Graphite
graphite.com › guides › typescript-operators
Operators in TypeScript
The in operator returns true if ... the question mark is used in two contexts. First, it can be used to denote optional properties in interfaces or objects....
🌐
TypeScript
typescriptlang.org › docs › handbook › 2 › objects.html
TypeScript: Documentation - Object Types
In those cases, we can mark those properties as optional by adding a question mark (?) to the end of their names. ... In this example, both xPos and yPos are considered optional. We can choose to provide either of them, so every call above to paintShape is valid.
🌐
Syncfusion
syncfusion.com › blogs › javascript › use of the exclamation mark in typescript
Use of the Exclamation Mark in TypeScript | Syncfusion Blogs
December 6, 2022 - In the above code example, you can see the use of ? after the parameter. In TypeScript, the question mark is used to define an argument as optional. It is the same as specifying the type as undefined.