{"id":90,"date":"2024-02-27T20:15:22","date_gmt":"2024-02-27T20:15:22","guid":{"rendered":"https:\/\/codefulsoul.blog\/?p=90"},"modified":"2024-03-04T21:30:16","modified_gmt":"2024-03-04T21:30:16","slug":"insider-10x-developer","status":"publish","type":"post","link":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/","title":{"rendered":"Insider 10x developer"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I can&#8217;t remember <code>HTMLDivElement<\/code> and <code>HTMLImageElement<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use u<code>seRef&lt;ElementRef&lt;'div'&gt;&gt;(null)<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Reminder: Complex types of inheritance are never worth it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Remember: satisfies and &#8220;as const&#8221; are incredible.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>as const satisfies [Sum, Mul]<\/code> are most times better than specifying the return type (Gives the caller back complete immutable types!)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Normalized Types from returns have problems. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Never use discriminated unions without a kind\/type property:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> \/\/ Obvious example\n function f(a: number) : ({x: number} | {y:number})\n {\n\n    if (a === 0) {\n        return {x: 3} as const;\n    }\n    return {y: 4} as const;\n  }\n\n\/\/ TS error\nconsole.log(f(0).x === undefined)\n\/\/ TS error\nconsole.log(f(0).y === undefined)\nconsole.log(f(3))\nconsole.log(f(3))\nconsole.log(f(3))\n\n\n\/\/ Not so obvious example\nfunction json&lt;T >(o: T) : T {\n    return o; \n}\n\n\nfunction f2(a: number)\n {\n\n    if (a === 0) {\n        return json({x: 9});\n    }\n    return json({y: 4});\n  }\n\nconst result: ReturnType&lt;typeof f2> = f2(3);\n\n\/\/ error\nconsole.log(f2(0).x === undefined)\n\/\/ error\nconsole.log(f2(0).y === undefined)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Sources<br>https:\/\/www.totaltypescript.com\/strongly-type-useref-with-elementref<br>https:\/\/twitter.com\/pcattori\/status\/1598359344827056131<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I can&#8217;t remember HTMLDivElement and HTMLImageElement Use useRef&lt;ElementRef&lt;&#8216;div&#8217;&gt;&gt;(null) Reminder: Complex types of inheritance are never worth it. Remember: satisfies and &#8220;as const&#8221; are incredible. as const satisfies [Sum, Mul] are most times better than specifying the return type (Gives the caller back complete immutable types!) Normalized Types from returns have problems. Never use discriminated unions [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[],"class_list":["post-90","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"I can&#039;t remember HTMLDivElement and HTMLImageElement Use useRef(null) Reminder: Complex types of inheritance are never worth it. Remember: satisfies and &quot;as const&quot; are incredible. as const satisfies [Sum, Mul] are most times better than specifying the return type (Gives the caller back complete immutable types!) Normalized Types from returns have problems. Never use discriminated unions\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Codeful Soul\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Codeful Soul -\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Insider 10x developer - Codeful Soul\" \/>\n\t\t<meta property=\"og:description\" content=\"I can&#039;t remember HTMLDivElement and HTMLImageElement Use useRef(null) Reminder: Complex types of inheritance are never worth it. Remember: satisfies and &quot;as const&quot; are incredible. as const satisfies [Sum, Mul] are most times better than specifying the return type (Gives the caller back complete immutable types!) Normalized Types from returns have problems. Never use discriminated unions\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2024-02-27T20:15:22+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-03-04T21:30:16+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Insider 10x developer - Codeful Soul\" \/>\n\t\t<meta name=\"twitter:description\" content=\"I can&#039;t remember HTMLDivElement and HTMLImageElement Use useRef(null) Reminder: Complex types of inheritance are never worth it. Remember: satisfies and &quot;as const&quot; are incredible. as const satisfies [Sum, Mul] are most times better than specifying the return type (Gives the caller back complete immutable types!) Normalized Types from returns have problems. Never use discriminated unions\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/#blogposting\",\"name\":\"Insider 10x developer - Codeful Soul\",\"headline\":\"Insider 10x developer\",\"author\":{\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/author\\\/ben\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/#organization\"},\"datePublished\":\"2024-02-27T20:15:22+00:00\",\"dateModified\":\"2024-03-04T21:30:16+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/#webpage\"},\"articleSection\":\"Uncategorized\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/codefulsoul.blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/codefulsoul.blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/category\\\/uncategorized\\\/#listItem\",\"name\":\"Uncategorized\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/category\\\/uncategorized\\\/#listItem\",\"position\":2,\"name\":\"Uncategorized\",\"item\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/category\\\/uncategorized\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/#listItem\",\"name\":\"Insider 10x developer\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/codefulsoul.blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/#listItem\",\"position\":3,\"name\":\"Insider 10x developer\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/category\\\/uncategorized\\\/#listItem\",\"name\":\"Uncategorized\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/#organization\",\"name\":\"Codeful Soul\",\"url\":\"https:\\\/\\\/codefulsoul.blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/author\\\/ben\\\/#author\",\"url\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/author\\\/ben\\\/\",\"name\":\"Codeful Soul\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/969221dac3055931987205f97839672b5ceda83e6a50ad8bf8a51e999a399907?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"Codeful Soul\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/#webpage\",\"url\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/\",\"name\":\"Insider 10x developer - Codeful Soul\",\"description\":\"I can't remember HTMLDivElement and HTMLImageElement Use useRef(null) Reminder: Complex types of inheritance are never worth it. Remember: satisfies and \\\"as const\\\" are incredible. as const satisfies [Sum, Mul] are most times better than specifying the return type (Gives the caller back complete immutable types!) Normalized Types from returns have problems. Never use discriminated unions\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/2024\\\/02\\\/27\\\/insider-10x-developer\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/author\\\/ben\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/index.php\\\/author\\\/ben\\\/#author\"},\"datePublished\":\"2024-02-27T20:15:22+00:00\",\"dateModified\":\"2024-03-04T21:30:16+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/#website\",\"url\":\"https:\\\/\\\/codefulsoul.blog\\\/\",\"name\":\"Codeful Soul\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/codefulsoul.blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Insider 10x developer - Codeful Soul","description":"I can't remember HTMLDivElement and HTMLImageElement Use useRef(null) Reminder: Complex types of inheritance are never worth it. Remember: satisfies and \"as const\" are incredible. as const satisfies [Sum, Mul] are most times better than specifying the return type (Gives the caller back complete immutable types!) Normalized Types from returns have problems. Never use discriminated unions","canonical_url":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/#blogposting","name":"Insider 10x developer - Codeful Soul","headline":"Insider 10x developer","author":{"@id":"https:\/\/codefulsoul.blog\/index.php\/author\/ben\/#author"},"publisher":{"@id":"https:\/\/codefulsoul.blog\/#organization"},"datePublished":"2024-02-27T20:15:22+00:00","dateModified":"2024-03-04T21:30:16+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/#webpage"},"isPartOf":{"@id":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/#webpage"},"articleSection":"Uncategorized"},{"@type":"BreadcrumbList","@id":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/codefulsoul.blog#listItem","position":1,"name":"Home","item":"https:\/\/codefulsoul.blog","nextItem":{"@type":"ListItem","@id":"https:\/\/codefulsoul.blog\/index.php\/category\/uncategorized\/#listItem","name":"Uncategorized"}},{"@type":"ListItem","@id":"https:\/\/codefulsoul.blog\/index.php\/category\/uncategorized\/#listItem","position":2,"name":"Uncategorized","item":"https:\/\/codefulsoul.blog\/index.php\/category\/uncategorized\/","nextItem":{"@type":"ListItem","@id":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/#listItem","name":"Insider 10x developer"},"previousItem":{"@type":"ListItem","@id":"https:\/\/codefulsoul.blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/#listItem","position":3,"name":"Insider 10x developer","previousItem":{"@type":"ListItem","@id":"https:\/\/codefulsoul.blog\/index.php\/category\/uncategorized\/#listItem","name":"Uncategorized"}}]},{"@type":"Organization","@id":"https:\/\/codefulsoul.blog\/#organization","name":"Codeful Soul","url":"https:\/\/codefulsoul.blog\/"},{"@type":"Person","@id":"https:\/\/codefulsoul.blog\/index.php\/author\/ben\/#author","url":"https:\/\/codefulsoul.blog\/index.php\/author\/ben\/","name":"Codeful Soul","image":{"@type":"ImageObject","@id":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/969221dac3055931987205f97839672b5ceda83e6a50ad8bf8a51e999a399907?s=96&d=identicon&r=g","width":96,"height":96,"caption":"Codeful Soul"}},{"@type":"WebPage","@id":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/#webpage","url":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/","name":"Insider 10x developer - Codeful Soul","description":"I can't remember HTMLDivElement and HTMLImageElement Use useRef(null) Reminder: Complex types of inheritance are never worth it. Remember: satisfies and \"as const\" are incredible. as const satisfies [Sum, Mul] are most times better than specifying the return type (Gives the caller back complete immutable types!) Normalized Types from returns have problems. Never use discriminated unions","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/codefulsoul.blog\/#website"},"breadcrumb":{"@id":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/#breadcrumblist"},"author":{"@id":"https:\/\/codefulsoul.blog\/index.php\/author\/ben\/#author"},"creator":{"@id":"https:\/\/codefulsoul.blog\/index.php\/author\/ben\/#author"},"datePublished":"2024-02-27T20:15:22+00:00","dateModified":"2024-03-04T21:30:16+00:00"},{"@type":"WebSite","@id":"https:\/\/codefulsoul.blog\/#website","url":"https:\/\/codefulsoul.blog\/","name":"Codeful Soul","inLanguage":"en-US","publisher":{"@id":"https:\/\/codefulsoul.blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Codeful Soul -","og:type":"article","og:title":"Insider 10x developer - Codeful Soul","og:description":"I can't remember HTMLDivElement and HTMLImageElement Use useRef(null) Reminder: Complex types of inheritance are never worth it. Remember: satisfies and &quot;as const&quot; are incredible. as const satisfies [Sum, Mul] are most times better than specifying the return type (Gives the caller back complete immutable types!) Normalized Types from returns have problems. Never use discriminated unions","og:url":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/","article:published_time":"2024-02-27T20:15:22+00:00","article:modified_time":"2024-03-04T21:30:16+00:00","twitter:card":"summary_large_image","twitter:title":"Insider 10x developer - Codeful Soul","twitter:description":"I can't remember HTMLDivElement and HTMLImageElement Use useRef(null) Reminder: Complex types of inheritance are never worth it. Remember: satisfies and &quot;as const&quot; are incredible. as const satisfies [Sum, Mul] are most times better than specifying the return type (Gives the caller back complete immutable types!) Normalized Types from returns have problems. Never use discriminated unions"},"aioseo_meta_data":{"post_id":"90","title":null,"description":null,"keywords":[],"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2024-02-27 20:15:22","updated":"2025-06-03 19:39:19","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/codefulsoul.blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/codefulsoul.blog\/index.php\/category\/uncategorized\/\" title=\"Uncategorized\">Uncategorized<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tInsider 10x developer\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/codefulsoul.blog"},{"label":"Uncategorized","link":"https:\/\/codefulsoul.blog\/index.php\/category\/uncategorized\/"},{"label":"Insider 10x developer","link":"https:\/\/codefulsoul.blog\/index.php\/2024\/02\/27\/insider-10x-developer\/"}],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/posts\/90","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/comments?post=90"}],"version-history":[{"count":4,"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/posts\/90\/revisions"}],"predecessor-version":[{"id":95,"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/posts\/90\/revisions\/95"}],"wp:attachment":[{"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/media?parent=90"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/categories?post=90"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codefulsoul.blog\/index.php\/wp-json\/wp\/v2\/tags?post=90"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}