<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/type-assertions-in-typescript---why-not--lunsnpvvy" -->

---
title: Type Assertions in TypeScript - why not? | daily.dev
description: Type assertions in TypeScript (using `as` or angle bracket syntax) bypass the compiler&#x27;s type checking, which can introduce subtle bugs. The non-null assertion...
canonical: https://daily.dev/posts/type-assertions-in-typescript---why-not--lunsnpvvy
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Type Assertions in TypeScript - why not? | daily.dev
og:description: Type assertions in TypeScript (using `as` or angle bracket syntax) bypass the compiler&#x27;s type checking, which can introduce subtle bugs. The non-null assertion...
og:url: https://daily.dev/posts/type-assertions-in-typescript---why-not--lunsnpvvy
og:image: https://api.daily.dev/og/posts/LuNSnpvvy.png
og:image:alt: Type Assertions in TypeScript - why not?
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.

# Type Assertions in TypeScript - why not?

**[Playful Programming](https://daily.dev/sources/playfulprogramming)** · [@mainawycliffe](https://daily.dev/mainawycliffe) · 4 min read · 0 upvotes · 0 comments

## Summary

Type assertions in TypeScript (using `as` or angle bracket syntax) bypass the compiler's type checking, which can introduce subtle bugs. The non-null assertion operator (`!`) carries similar risks, especially with external API types like environment variables. Better alternatives include type narrowing via type guards, truthiness checks, custom type guard functions, and providing default values using the nullish coalescing (`??`) or logical OR (`||`) operators.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://playfulprogramming.com/posts/type-assertions-in-typescript-why-not-2jc3>

## Similar posts on daily.dev

- [Stop Using TypeScript's Exclamation Mark](https://daily.dev/posts/stop-using-typescript-s-exclamation-mark-re1atfub4) · TypeScript.TV · 258 upvotes · 16 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/type-assertions-in-typescript---why-not--lunsnpvvy)

```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":"Type Assertions in TypeScript - why not?","url":"https://daily.dev/posts/type-assertions-in-typescript---why-not--lunsnpvvy","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/type-assertions-in-typescript---why-not--lunsnpvvy"},"datePublished":"2026-03-16T21:47:31.386Z","dateModified":"2026-03-17T18:02:26.340Z","description":"Type assertions in TypeScript (using `as` or angle bracket syntax) bypass the compiler's type checking, which can introduce subtle bugs. The non-null assertion...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/da44e545780705e4cb7a0b662675ea17?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/da44e545780705e4cb7a0b662675ea17?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Playful Programming","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":"Person","name":"Maina Wycliffe","url":"https://daily.dev/mainawycliffe","image":"https://lh3.googleusercontent.com/a-/AOh14GixkCfcFRGynHA6Q1do3acrQ2SJInlspCdn2KXZWw=s100","description":"Web Developer and Google Developer Expert","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":50}},"commentCount":0,"discussionUrl":"https://daily.dev/posts/type-assertions-in-typescript---why-not--lunsnpvvy","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"javascript,typescript","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Playful Programming","item":"https://daily.dev/sources/playfulprogramming"},{"@type":"ListItem","position":3,"name":"Type Assertions in TypeScript - why not?"}]}
```

