This is a autopost bolg frinds we are trying to all latest sports,news,all new update provide for you
Monday, April 21, 2025
Show HN: I made TypeScript's type inference more strict (and smarter) https://ift.tt/MbiPZXW
Show HN: I made TypeScript's type inference more strict (and smarter) As a TypeScript developer, I often found myself wishing the type system could do more—*especially when omitting or modifying deeply nested properties* inside complex objects and arrays. For instance, what if I want to remove a deeply nested field like `user.profile.email` and also something like `user.posts[ ].meta.shares` from a type? TypeScript doesn't really provide a built-in way to do that. So I built *DeepStrictTypes* — a utility that lets you *omit deeply nested keys*, even inside arrays, with full type inference and strictness. Here’s an example: ```ts type Example = { user: { id: string; profile: { name: string; age: number; email: string; }; posts: { title: string; content: string; meta: { likes: number; shares: number; }; }[]; }; }; // Remove 'user.profile.email' and 'user.posts[ ].meta.shares' type Omitted = DeepStrictOmit< Example, 'user.profile.email' | 'user.posts[*].meta.shares' >; ``` The resulting type: ```ts { user: { id: string; profile: { name: string; age: number; }; posts: { title: string; content: string; meta: { likes: number; }; }[]; }; } ``` Works great for: - Cleaning up types for API responses - Dynamically transforming deeply nested data - Improving type safety when handling structured JSON [ https://ift.tt/X2FrN68 ]( https://ift.tt/X2FrN68 ) Would love your feedback or ideas for improvements! https://ift.tt/yFqxuiR April 22, 2025 at 09:17AM
Subscribe to:
Post Comments (Atom)
Show HN: We post-trained a model that pen tests instead of refusing https://ift.tt/W4x1YnM
Show HN: We post-trained a model that pen tests instead of refusing Anthropic and OpenAI's publicly available models are explicitly guar...
-
Show HN: When is the next Caltrain? (minimal webapp) I was frustrated with the existing caltrain websites / apps, so I made a super minimali...
-
Show HN: I built Dirac, Hash Anchored AST native coding agent, costs -64.8 pct Fully open source, a hard fork of cline. Full evals on the gi...
-
Show HN: A directory of 800 free APIs, no auth required Explore reliable free APIs for developers — ideal for web and software development, ...
No comments:
Post a Comment