<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/stop-using-typescript-s-exclamation-mark-re1atfub4" -->

---
title: Stop Using TypeScript&#x27;s Exclamation Mark | daily.dev
description: The non-null assertion operator (!) in TypeScript bypasses type safety by forcing the compiler to treat potentially nullable values as non-null, leading to...
canonical: https://daily.dev/posts/stop-using-typescript-s-exclamation-mark-re1atfub4
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Stop Using TypeScript&#x27;s Exclamation Mark | daily.dev
og:description: The non-null assertion operator (!) in TypeScript bypasses type safety by forcing the compiler to treat potentially nullable values as non-null, leading to...
og:url: https://daily.dev/posts/stop-using-typescript-s-exclamation-mark-re1atfub4
og:image: https://api.daily.dev/og/posts/re1atFUB4.png
og:image:alt: Stop Using TypeScript&#x27;s Exclamation Mark
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Stop Using TypeScript's Exclamation Mark

**[TypeScript.TV](https://daily.dev/sources/typescripttv)** · 6 min read · 258 upvotes · 16 comments

## Summary

The non-null assertion operator (!) in TypeScript bypasses type safety by forcing the compiler to treat potentially nullable values as non-null, leading to runtime crashes. Instead of using this operator, developers should employ safer alternatives: optional chaining for nested property access, nullish coalescing for default values, conditional operators for explicit branching, type guards for reusable validation, and assertion functions for enforcing invariants. These approaches maintain type safety while handling null and undefined values appropriately, following fail-fast principles and preventing silent failures.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://typescript.tv/best-practices/stop-using-typescripts-exclamation-mark/>

## Community discussion

Top comments from developers on daily.dev.

**@elisherer** · 18 upvotes

> I don't agree, there are occasions I want to say that "I know" this is not null, for example process.env.* , it is defined as a string | undefined.. but I know it has a value and I don't want needlessly to check for null.

**@stefanaleksandrov** · 10 upvotes

> Every tool has its use case and purpose, never say never.

**@arifmahmudrana** · 6 upvotes

> Can't agree more.

**@a\_meb\_a** · 5 upvotes

> never say never, I believe in TS supremacy

**@akkitto** · 5 upvotes

> Same with Kotlin. It's an anti-pattern, ***only*** to be used for quick & dirty prototyping. Not something I would even run in a development environment outside of my computer.

## Similar posts on daily.dev

- [JavaScript’s ??= Operator: Default Values Made Simple – Frontend Masters Blog](https://daily.dev/posts/javascript-s-operator-default-values-made-simple-frontend-masters-blog-bybsiyhek) · Frontend Masters · 1 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#nodejs](https://daily.dev/tags/nodejs), [#typescript](https://daily.dev/tags/typescript)

[View this post on daily.dev](https://daily.dev/posts/stop-using-typescript-s-exclamation-mark-re1atfub4)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Stop Using TypeScript's Exclamation Mark","url":"https://daily.dev/posts/stop-using-typescript-s-exclamation-mark-re1atfub4","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/stop-using-typescript-s-exclamation-mark-re1atfub4"},"datePublished":"2025-12-11T14:44:02.639Z","dateModified":"2025-12-11T14:44:22.382Z","description":"The non-null assertion operator (!) in TypeScript bypasses type safety by forcing the compiler to treat potentially nullable values as non-null, leading to...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0abb27e5fa0635516fee4b38ad6c1a47?_a=AQAEulh","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0abb27e5fa0635516fee4b38ad6c1a47?_a=AQAEulh","isAccessibleForFree":true,"articleSection":"TypeScript.TV","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"TypeScript.TV","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/57ce30b9764a474caf60a5b81549c1b3","url":"https://daily.dev/sources/typescripttv"},"commentCount":16,"discussionUrl":"https://daily.dev/posts/stop-using-typescript-s-exclamation-mark-re1atfub4","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":258},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":16}],"keywords":"testing,nodejs,typescript","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"TypeScript.TV","item":"https://daily.dev/sources/typescripttv"},{"@type":"ListItem","position":3,"name":"Stop Using TypeScript's Exclamation Mark"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/stop-using-typescript-s-exclamation-mark-re1atfub4","comment":[{"@type":"Comment","text":"I don’t agree, there are occasions I want to say that “I know” this is not null, for example process.env.* , it is defined as a string | undefined… but I know it has a value and I don’t want needlessly to check for null.","datePublished":"2025-12-12T12:05:32.354Z","url":"https://daily.dev/posts/re1atFUB4#c-zypFqaM9Z","author":{"@type":"Person","name":"Eli Sherer","url":"https://daily.dev/elisherer","image":"https://lh3.googleusercontent.com/a/ACg8ocL-zJCtdk1b16v77PNO_JBe22Sj3tRVCb6FQ8yEejd46ztw5Td6OA=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":18}},{"@type":"Comment","text":"Every tool has its use case and purpose, never say never.","datePublished":"2025-12-17T08:42:44.213Z","url":"https://daily.dev/posts/re1atFUB4#c-RP3zkoSlK","author":{"@type":"Person","name":"Stefan Aleksandrov","url":"https://daily.dev/stefanaleksandrov","image":"https://lh3.googleusercontent.com/a/ACg8ocK18H_LozELbngA6X0TCD_YTsjwQdTzRP8OEDlZ7H9Q9k21lA=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":10}},{"@type":"Comment","text":"Can’t agree more.","datePublished":"2025-12-12T09:59:33.648Z","url":"https://daily.dev/posts/re1atFUB4#c-z6E4cZblG","author":{"@type":"Person","name":"Arif Mahmud Rana","url":"https://daily.dev/arifmahmudrana","image":"https://avatars.githubusercontent.com/u/2046796?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":6}},{"@type":"Comment","text":"never say never, I believe in TS supremacy","datePublished":"2025-12-17T11:06:13.714Z","url":"https://daily.dev/posts/re1atFUB4#c-b7iHWkPR8","author":{"@type":"Person","name":"Phillippe Michel Weir","url":"https://daily.dev/a_meb_a","image":"https://media.daily.dev/image/upload/s--BwH-uTMq--/f_auto/v1740136991/avatars/avatar_N403VFK9lAHNRwlSAhl1h"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5}},{"@type":"Comment","text":"Same with Kotlin. It’s an anti-pattern, only to be used for quick &amp; dirty prototyping. Not something I would even run in a development environment outside of my computer.","datePublished":"2025-12-12T10:21:03.053Z","url":"https://daily.dev/posts/re1atFUB4#c-aXgPYmu1U","author":{"@type":"Person","name":"Daniel","url":"https://daily.dev/akkitto","image":"https://media.daily.dev/image/upload/s--FtwJqX4c--/f_auto/v1754900041/avatars/avatar_29TCpY2hJR72V3BlxPXzX?_a=BAMClqZW0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5}}]}
```

