<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Snippets on pleto.dev</title>
    <link>https://pleto.dev/snippets/</link>
    <description>Recent content in Snippets on pleto.dev</description>
    <image>
      <title>pleto.dev</title>
      <url>https://pleto.dev/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://pleto.dev/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 13 Jan 2024 11:32:43 +0200</lastBuildDate>
    <atom:link href="https://pleto.dev/snippets/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Typescript: Field masks - construct type based on input parameter</title>
      <link>https://pleto.dev/snippets/typescript-return-type-based-on-input-parameter/</link>
      <pubDate>Sat, 13 Jan 2024 11:32:43 +0200</pubDate>
      <guid>https://pleto.dev/snippets/typescript-return-type-based-on-input-parameter/</guid>
      <description>Field masks are a way for API callers to list the fields that a request should return or update: read more about them here. When working with field masks, checks usually happen at run-time and through tests.
After some work, I figured out how to take advantage of TypeScript&amp;rsquo;s type system, so one can also leverage compile-time checks.
I wrote two snippets to showcase it:
The first one retrieves only top-level fields of a structure (goto implementation) let data = getPartialData([&amp;#39;id&amp;#39;, &amp;#39;settings&amp;#39;]) // data contains ONLY `id` and `settings` fields The second one fetches fields at a specified depth within a structure (goto implementation).</description>
    </item>
  </channel>
</rss>
