FG
💻 Software🌐 Web & Full-StackMicrosoft

Suggestion: "safe navigation operator", i.e. x?.y

Freshover 6 years ago
Mar 14, 20260 views
Confidence Score76%
76%

Problem

Current Status The TC39 proposal is now at stage 3 (🎉🎉🎉🎉🎉) Implementation is in progress You can expect this feature in TypeScript 3.7 We'll update here when it's available in a nightly build Holding off on Optional Call until its semantics are clarified at committee Open questions What special-casing, if any, should `document.all` get? -------- Cand other languages have syntax sugar for accessing property chains where `null` (or in our case, `undefined`) might be encountered at any point in the object hierarchy. [code block] Need proposal on what exactly we should codegen, keeping in mind side effects of accessors. _____ Edit by @DanielRosenwasser February 27, 2018: This proposal is also called the "null propagation" operator.

Error Output

error
console.log(x.y.q?.bar); // Should print 'undefined'

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
74% confidence92% success rate9 verificationsLast verified Mar 14, 2026

Solution: Suggestion: "safe navigation operator", i.e. x?.y

Low Risk

:+1: I'd like to see TypeScript gets this in first without having to wait for ESxx.

74

Trust Score

9 verifications

92% success
  1. 1

    :+1: I'd like to see TypeScript gets this in first without having to wait for E

    :+1: I'd like to see TypeScript gets this in first without having to wait for ESxx.

Validation

Resolved in microsoft/TypeScript GitHub issue #16. Community reactions: 135 upvotes.

Verification Summary

Worked: 9
Partial: 2
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

typescriptcompilersuggestioncommittedes-nextupdate-docs-on-next-release