<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/when-a-type-guard-knows-more-than-its-return-type-cmeykxxuz" -->

---
title: When a Type Guard Knows More Than Its Return Type
description: Explores why extracting an inline TypeScript type guard into a reusable function can lose the compiler's ability to narrow both the AST node and one of its...
canonical: https://daily.dev/posts/when-a-type-guard-knows-more-than-its-return-type-cmeykxxuz
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: When a Type Guard Knows More Than Its Return Type | daily.dev
og:description: Explores why extracting an inline TypeScript type guard into a reusable function can lose the compiler's ability to narrow both the AST node and one of its...
og:url: https://daily.dev/posts/when-a-type-guard-knows-more-than-its-return-type-cmeykxxuz
og:image: https://api.daily.dev/og/posts/cmeykxXUz.png
og:image:alt: When a Type Guard Knows More Than Its Return Type
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.

# When a Type Guard Knows More Than Its Return Type

**[nyaomaru](https://daily.dev/sources/graxwfjk0eop4zs3tdzdr)** · [@nyaomaru](https://daily.dev/nyaomaru) · 1 min read · 0 upvotes · 0 comments

## Summary

Explores why extracting an inline TypeScript type guard into a reusable function can lose the compiler's ability to narrow both the AST node and one of its child properties simultaneously, and discusses techniques to retain that narrowed information when refactoring such checks into standalone functions.

## Content

Inline TypeScript can preserve both a narrowed AST node and one of its child properties.

Extract the same check into a reusable function, though, and that precision can disappear.

I’ve been digging into why, and how to keep the runtime fact attached to the parent type.

#typescript #type-safety #webdev

## Similar posts on daily.dev

- [Type inference and narrowing with reverse arrows](https://daily.dev/posts/type-inference-and-narrowing-with-reverse-arrows-assmagocy) · Elixir · 10 upvotes · 0 comments

---

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

[View this post on daily.dev](https://daily.dev/posts/when-a-type-guard-knows-more-than-its-return-type-cmeykxxuz)

```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":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/when-a-type-guard-knows-more-than-its-return-type-cmeykxxuz","headline":"When a Type Guard Knows More Than Its Return Type","text":"Explores why extracting an inline TypeScript type guard into a reusable function can lose the compiler's ability to narrow both the AST node and one of its child properties simultaneously, and discusses techniques to retain that narrowed information when refactoring such checks into standalone functions.","url":"https://daily.dev/posts/when-a-type-guard-knows-more-than-its-return-type-cmeykxxuz","datePublished":"2026-09-25T16:30:04.918Z","dateModified":"2026-09-25T16:30:19.076Z","author":{"@type":"Person","name":"nyaomaru","url":"https://daily.dev/nyaomaru","image":"https://avatars.githubusercontent.com/u/90489696?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":450}},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/graxwfjk0eop4zs3tdzdr","name":"nyaomaru"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"nyaomaru","item":"https://daily.dev/sources/graxwfjk0eop4zs3tdzdr"},{"@type":"ListItem","position":3,"name":"When a Type Guard Knows More Than Its Return Type"}]}
```

