<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/why-doesn-t-typescript-properly-type-object-keys--ts2yjk4xv" -->

---
title: Why doesn’t TypeScript properly type Object.keys?
description: TypeScript types Object.keys to return string[] instead of (keyof T)[] due to its structural type system. Because an object typed as T may contain additional...
canonical: https://daily.dev/posts/why-doesn-t-typescript-properly-type-object-keys--ts2yjk4xv
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Why doesn’t TypeScript properly type Object.keys? | daily.dev
og:description: TypeScript types Object.keys to return string[] instead of (keyof T)[] due to its structural type system. Because an object typed as T may contain additional...
og:url: https://daily.dev/posts/why-doesn-t-typescript-properly-type-object-keys--ts2yjk4xv
og:image: https://api.daily.dev/og/posts/ts2yJk4Xv.png
og:image:alt: Why doesn’t TypeScript properly type Object.keys?
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.

# Why doesn’t TypeScript properly type Object.keys?

**[Alex Harri](https://daily.dev/sources/alexharri)** · 7 min read · 0 upvotes · 0 comments

## Summary

TypeScript types Object.keys to return string[] instead of (keyof T)[] due to its structural type system. Because an object typed as T may contain additional properties at runtime that TypeScript isn't aware of, returning keyof T would be unsafe — it could lead to accessing undefined validators or properties. The post explains structural typing with concrete examples, shows how extraneous properties are allowed by design, and demonstrates how to leverage structural typing positively by defining minimal interfaces that only declare the properties a function actually needs.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://alexharri.com/blog/typescript-structural-typing>

---

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

[View this post on daily.dev](https://daily.dev/posts/why-doesn-t-typescript-properly-type-object-keys--ts2yjk4xv)

```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":"Why doesn’t TypeScript properly type Object.keys?","url":"https://daily.dev/posts/why-doesn-t-typescript-properly-type-object-keys--ts2yjk4xv","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/why-doesn-t-typescript-properly-type-object-keys--ts2yjk4xv"},"datePublished":"2026-03-31T12:29:37.503Z","dateModified":"2026-03-31T12:53:59.928Z","description":"TypeScript types Object.keys to return string[] instead of (keyof T)[] due to its structural type system. Because an object typed as T may contain additional...","image":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","thumbnailUrl":"https://media.daily.dev/image/upload/s--VDukGCjf--/f_auto/v1722860399/public/Placeholder%2002","isAccessibleForFree":true,"articleSection":"Alex Harri","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":"Alex Harri","logo":"https://media.daily.dev/image/upload/s--bdkrSn23--/f_auto,q_auto/v1774960051/logos/alexharri?_a=BAMAMiWQ0","url":"https://daily.dev/sources/alexharri"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/why-doesn-t-typescript-properly-type-object-keys--ts2yjk4xv","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"typescript","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Alex Harri","item":"https://daily.dev/sources/alexharri"},{"@type":"ListItem","position":3,"name":"Why doesn’t TypeScript properly type Object.keys?"}]}
```

