October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

Angular NG8102: Nullish Coalescing Not Nullable

NG8102 flags a template’s ?? fallback when its left-hand value is typed as non-nullable. Fix the mismatch by correcting the type or removing the unreachable fallback.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Angular’s NG8102 warning means a template uses ?? on a value whose declared type cannot be null or undefined. The fallback on the right therefore cannot run. To fix it, make the type nullable if the value can genuinely be absent, or remove the fallback if the value is guaranteed to exist.

What NG8102 means

NG8102, named nullishCoalescingNotNullable, flags a nullish-coalescing expression in an Angular template when the value before ?? is typed as non-nullable. For example, if a component declares username: string, then {{ username ?? 'root' }} has an unreachable fallback: the declared type says username is always a string. Angular describes the warning as a signal that the type declaration and the way the template handles the value may not agree. See Angular’s NG8102 documentation.

As an Amazon Associate I earn from qualifying purchases.

The operator itself is supported in Angular templates. It returns the value on the left unless that value is null or undefined; only then does it use the expression on the right. The expression’s type is determined in its template context, which can include the component class and template locals. See Angular template expression syntax.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why Angular shows the warning

The compiler sees two conflicting signals: the TypeScript type says the value cannot be nullish, while the template includes a fallback for exactly that possibility. Resolving the mismatch makes the code’s declared behavior clearer and prevents an ineffective fallback from hiding an incorrect type.

NG8102 is emitted only when both strictTemplates and TypeScript’s strictNullChecks are enabled. Angular’s extended diagnostics generally require strict template checking; this particular check also requires strict null checking. If the warning does not appear, those settings may not both be active. See the Angular extended diagnostics overview.

Choose the fix that matches the value

If the value can really be absent

Include the possible nullish value in its type and keep the fallback if that is the intended display behavior:

username: string | null = null;
{{ username ?? 'root' }}

Use the type that matches the data your application can actually receive. For instance, an API field or optional application state may be absent; represent that possibility accurately instead of claiming the value is always a string.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If the value is guaranteed to exist

Remove the operator and fallback. A non-nullable string can be rendered directly:

username: string = 'Ada';
{{ username }}

Do not add null or undefined to a type merely to silence NG8102. Doing so tells the rest of the application that absence is possible even when it is not, weakening the usefulness of the type information.

Configure the diagnostic separately from fixing the code

Angular extended diagnostics are warnings by default. In tsconfig.json, a project can set an individual check to warning, error, or suppress under angularCompilerOptions.extendedDiagnostics.checks. The NG8102 key is nullishCoalescingNotNullable.

{
  "angularCompilerOptions": {
    "extendedDiagnostics": {
      "checks": {
        "nullishCoalescingNotNullable": "suppress"
      }
    }
  }
}

Suppression removes the diagnostic feedback; it does not make the fallback reachable or correct a type that misrepresents the data. Choose severity according to project policy, but resolve the type-versus-template mismatch when it reflects a real inconsistency. Angular notes that it may add or enable extended diagnostics in minor releases, so review the current diagnostics documentation when changing framework versions or diagnostic policy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How NG8102 differs from NG8107

NG8102 concerns ?? on a non-nullable value. NG8107 concerns optional chaining, ?., when the value on the left is non-nullable. Both warnings point to a potentially unnecessary operator, but the template behavior differs: one supplies a nullish fallback, while the other conditionally accesses a property or method. Before removing either operator, check whether the declared type accurately reflects whether the value can be absent. See Angular’s NG8107 documentation.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.