[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"verticals":3,"article-typescript-noinfer-generic-widening":44,"search-suggestions":259,"path-membership-typescript-noinfer-generic-widening":300,"related-typescript-noinfer-generic-widening":301,"code:ts:true:xu8yk3":426,"code:ts:true:18e9lu7":427,"code:ts:true:zmpdsh":428,"code:ts:true:1g19mc7":429,"code:ts:true:vs9lbu":430,"comments-01a1df1b-32db-7638-a86f-5cea99530919":431},[4,20,32],{"id":5,"slug":6,"name":7,"tagline":8,"description":9,"accentFrom":10,"accentTo":11,"icon":12,"defaultLocale":13,"locales":14,"features":16,"position":19},"019fe637-3d33-714b-b57f-23e163ffca0c","dev","Web Development","Read it. Run it. Prove it.","A post a day on modern web development — most with an editable playground and a quiz that explains every answer. Free, no account needed.","violet-500","cyan-400","◇","en",[13,15],"fa",{"courses":17,"paths":17,"articles":17,"exams":18,"flashcards":18,"packages":17,"community":17,"certificates":17,"teams":17,"commerce":17},true,false,0,{"id":21,"slug":22,"name":23,"tagline":24,"description":25,"accentFrom":26,"accentTo":10,"icon":27,"defaultLocale":13,"locales":28,"features":30,"position":31},"019fe637-3dc2-754c-8657-0f175bfee7c6","lang","Languages","Learn a language the way you learn a codebase.","Grammar explained the way good documentation explains an API — one idea at a time, each with a quiz.","amber-400","⌘",[13,15,29],"es",{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":17,"packages":18,"community":17,"certificates":17,"teams":18,"commerce":18},2,{"id":33,"slug":34,"name":35,"tagline":36,"description":37,"accentFrom":38,"accentTo":39,"icon":40,"defaultLocale":13,"locales":41,"features":42,"position":43},"7b3c16f2-931d-410e-802e-e1fa4edab7de","soft","Soft Skills","The half of the job nobody wrote documentation for.","Weekly, on the parts of working life that decide more than your code does — first weeks, meetings, interviews, promotions, and the people around you. Written from what actually happens, and recorded as a podcast you can listen to on the walk.","emerald-400","teal-300","◉",[13],{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":18,"packages":18,"community":17,"certificates":18,"teams":18,"commerce":18},3,{"id":45,"slug":46,"title":47,"subtitle":48,"excerpt":49,"coverUrl":50,"locale":13,"readingMinutes":51,"publishedAt":52,"viewCount":53,"likeCount":19,"commentCount":19,"author":54,"vertical":59,"topic":60,"tags":63,"_count":75,"playground":77,"body":79,"bodyMd":243,"seo":244,"translationGroupId":246,"series":48,"podcastUrl":48,"verticalId":5,"thread":247,"assessments":249,"translations":255,"quiz":257},"01a1df1b-32db-7638-a86f-5cea99530919","typescript-noinfer-generic-widening","A Typo Widened My Generic Instead of Erroring. NoInfer\u003CT> Fixes It.",null,"Why a typo'd default argument sailed through a generic function with zero errors — and how TypeScript's NoInfer\u003CT> stops it from silently widening the inferred type.","\u002Fmedia\u002Fcovers\u002Ftypescript-noinfer-generic-widening.png",5,"2026-11-27T11:45:27.674Z",9,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},"019fe637-3c25-7088-9034-39c9f15dc3c8","Parsa Jiravand","parsa","Frontend engineer · building bestpractic",{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},"typescript","TypeScript",[64,66,69,72],{"slug":61,"name":65,"color":48},"Typescript",{"slug":67,"name":68,"color":48},"javascript","Javascript",{"slug":70,"name":71,"color":48},"programming","Programming",{"slug":73,"name":74,"color":48},"webdev","Webdev",{"assessments":76},1,{"slug":46,"title":78},"NoInfer&lt;T&gt; — interactive playground",{"blocks":80,"version":76},[81,85,91,94,97,100,104,107,111,114,117,121,124,127,130,133,137,140,143,146,149,152,155,159,162,166,169,172,175,179,182,185,188,191,194,197,200,203,206,209,212,215,218,225,228,231,234,237],{"id":82,"html":83,"type":84},"b1","\u003Cp>Someone on the team adds a new feature flag, wires up its default, and opens a PR:\u003C\u002Fp>","paragraph",{"id":86,"code":87,"type":88,"language":89,"highlight":90},"b2","defineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"darkmode\");","code","ts",[],{"id":92,"html":93,"type":84},"b3","\u003Cp>One lowercase \u003Ccode>m\u003C\u002Fcode>. Nobody catches it in review — the build is green, the editor shows no red squiggle, \u003Ccode>defineFlags\u003C\u002Fcode> is fully generic and type-safe by every measure anyone checked. It merges.\u003C\u002Fp>",{"id":95,"html":96,"type":84},"b4","\u003Cp>Three days later the settings panel that reads this default renders a blank icon, because the lookup table keyed by flag name has no entry for \u003Ccode>&quot;darkmode&quot;\u003C\u002Fcode> — only \u003Ccode>&quot;darkMode&quot;\u003C\u002Fcode>. The function whose entire job was to make this exact typo impossible let it straight through, silently.\u003C\u002Fp>",{"id":98,"html":99,"type":84},"b5","\u003Cp>The fix is one word. Understanding why TypeScript needed it took longer.\u003C\u002Fp>",{"id":101,"html":102,"text":102,"type":103,"level":31},"b6","The function looked airtight","heading",{"id":105,"html":106,"type":84},"b7","\u003Cp>Here&#39;s roughly what \u003Ccode>defineFlags\u003C\u002Fcode> looked like:\u003C\u002Fp>",{"id":108,"code":109,"type":88,"language":89,"highlight":110},"b8","function defineFlags\u003CName extends string>(\n  names: Name[],\n  defaultFlag?: Name\n) {\n  return { names, defaultFlag };\n}",[],{"id":112,"html":113,"type":84},"b9","\u003Cp>This reads like it should be bulletproof. \u003Ccode>Name\u003C\u002Fcode> is inferred from the array you pass in, so \u003Ccode>defaultFlag\u003C\u002Fcode> has to be one of those exact strings — that&#39;s the whole point of writing it generic instead of typing both parameters as \u003Ccode>string\u003C\u002Fcode>.\u003C\u002Fp>",{"id":115,"html":116,"type":84},"b10","\u003Cp>Spot the bug yet? Try it before you scroll: paste this into a \u003Ccode>.ts\u003C\u002Fcode> file and see what the compiler says.\u003C\u002Fp>",{"id":118,"code":119,"type":88,"language":89,"highlight":120},"b11","defineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"newCheckout\"); \u002F\u002F fine\ndefineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"darkmode\");    \u002F\u002F ???",[],{"id":122,"html":123,"type":84},"b12","\u003Cp>Zero errors. Both lines. The second one — the typo — compiles exactly as cleanly as the first.\u003C\u002Fp>",{"id":125,"html":126,"text":126,"type":103,"level":31},"b13","What TypeScript was actually inferring",{"id":128,"html":129,"type":84},"b14","\u003Cp>Here&#39;s the part that&#39;s easy to get wrong: TypeScript doesn&#39;t treat the array argument as &quot;the source of truth&quot; for \u003Ccode>Name\u003C\u002Fcode> and then check \u003Ccode>defaultFlag\u003C\u002Fcode> against it. It collects a \u003Cem>candidate\u003C\u002Fem> type from every position where \u003Ccode>Name\u003C\u002Fcode> appears unannotated, across the whole call, and only then decides what \u003Ccode>Name\u003C\u002Fcode> is.\u003C\u002Fp>",{"id":131,"html":132,"type":84},"b15","\u003Cp>\u003Ccode>names\u003C\u002Fcode> offers \u003Ccode>&quot;darkMode&quot; | &quot;newCheckout&quot; | &quot;betaSearch&quot;\u003C\u002Fcode> as a candidate. \u003Ccode>defaultFlag\u003C\u002Fcode> offers whatever you passed — including \u003Ccode>&quot;darkmode&quot;\u003C\u002Fcode> — as another candidate. TypeScript doesn&#39;t pick one and validate the other against it. It unions them. \u003Ccode>Name\u003C\u002Fcode> quietly becomes \u003Ccode>&quot;darkMode&quot; | &quot;newCheckout&quot; | &quot;betaSearch&quot; | &quot;darkmode&quot;\u003C\u002Fcode>, and under that definition, passing \u003Ccode>&quot;darkmode&quot;\u003C\u002Fcode> for a parameter of type \u003Ccode>Name\u003C\u002Fcode> is completely correct. You can watch it happen by forcing the inferred type into the open:\u003C\u002Fp>",{"id":134,"code":135,"type":88,"language":89,"highlight":136},"b16","function defineFlagsTyped\u003CName extends string>(\n  names: Name[],\n  defaultFlag?: Name\n): Name {\n  return names[0] as Name;\n}\n\nconst result = defineFlagsTyped(\n  [\"darkMode\", \"newCheckout\", \"betaSearch\"],\n  \"darkmode\"\n);\n\n\u002F\u002F Assigning the \"real\" union back reveals what Name actually became:\nconst check: \"darkMode\" | \"newCheckout\" | \"betaSearch\" = result;\n\u002F\u002F Type '\"darkMode\" | \"newCheckout\" | \"betaSearch\" | \"darkmode\"'\n\u002F\u002F is not assignable to type '\"darkMode\" | \"newCheckout\" | \"betaSearch\"'.",[],{"id":138,"html":139,"type":84},"b17","\u003Cp>\u003Ccode>Name\u003C\u002Fcode> picked up a fourth member nobody asked for. The typo isn&#39;t a value that failed a check — it&#39;s part of the type now.\u003C\u002Fp>",{"id":141,"html":142,"type":84},"b18","\u003C!-- playground:start -->",{"id":144,"html":145,"text":145,"type":103,"level":31},"b19","🎮 Try it yourself",{"id":147,"html":148,"type":84},"b20","\u003Cp>\u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-noinfer-generic-widening\u002Fplayground\">▶️ Open the interactive playground →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":150,"html":151,"type":84},"b21","\u003Cp>\u003Cem>Runs right in your browser — poke at it and watch the concept react live.\u003C\u002Fem>\u003C\u002Fp>",{"id":153,"html":154,"type":84},"b22","\u003C!-- playground:end -->",{"id":156,"html":157,"text":158,"type":103,"level":31},"b23","The fix: tell TypeScript which position doesn&#39;t get a vote","The fix: tell TypeScript which position doesn't get a vote",{"id":160,"html":161,"type":84},"b24","\u003Cp>\u003Ccode>defaultFlag\u003C\u002Fcode> was never supposed to help decide what \u003Ccode>Name\u003C\u002Fcode> is. It was supposed to be checked \u003Cem>against\u003C\u002Fem> a \u003Ccode>Name\u003C\u002Fcode> that the array had already settled. That&#39;s exactly what \u003Ccode>NoInfer&lt;T&gt;\u003C\u002Fcode> — built into TypeScript&#39;s standard library since 5.4 — exists to say:\u003C\u002Fp>",{"id":163,"code":164,"type":88,"language":89,"highlight":165},"b25","function defineFlags\u003CName extends string>(\n  names: Name[],\n  defaultFlag?: NoInfer\u003CName>\n) {\n  return { names, defaultFlag };\n}\n\ndefineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"newCheckout\"); \u002F\u002F fine\ndefineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"darkmode\");\n\u002F\u002F Argument of type '\"darkmode\"' is not assignable to parameter of type\n\u002F\u002F '\"darkMode\" | \"newCheckout\" | \"betaSearch\" | undefined'.",[],{"id":167,"html":168,"type":84},"b26","\u003Cp>Same call, same arguments — now the typo is a compile error, pointing at the exact argument, before the PR even opens.\u003C\u002Fp>",{"id":170,"html":171,"type":84},"b27","\u003Cp>\u003Ccode>NoInfer&lt;T&gt;\u003C\u002Fcode> doesn&#39;t change what \u003Ccode>Name\u003C\u002Fcode> \u003Cem>can\u003C\u002Fem> be; it changes who gets to decide. Wrapping a position in it removes that position from the pool of candidates TypeScript draws \u003Ccode>Name\u003C\u002Fcode> from, without removing the requirement that whatever you pass there still has to match. \u003Ccode>names\u003C\u002Fcode> is still the only thing allowed to say what \u003Ccode>Name\u003C\u002Fcode> is. \u003Ccode>defaultFlag\u003C\u002Fcode> has to agree with it, not contribute to it.\u003C\u002Fp>",{"id":173,"html":174,"type":84},"b28","\u003Cp>It&#39;s a type-only change — nothing about the function&#39;s runtime behavior moves. You&#39;re only narrowing which arguments count as evidence to the type checker.\u003C\u002Fp>",{"id":176,"html":177,"text":178,"type":103,"level":31},"b29","Where it won&#39;t save you","Where it won't save you",{"id":180,"html":181,"type":84},"b30","\u003Cp>\u003Ccode>NoInfer&lt;T&gt;\u003C\u002Fcode> only works at compile time, against types TypeScript can actually see. A typed value — even a plain \u003Ccode>string | undefined\u003C\u002Fcode> from \u003Ccode>process.env\u003C\u002Fcode> — still gets checked against the real \u003Ccode>Name\u003C\u002Fcode> and still gets rejected if it&#39;s wrong. The gap is narrower than &quot;anything not a literal&quot;: it&#39;s specifically \u003Ccode>any\u003C\u002Fcode>. \u003Ccode>JSON.parse()\u003C\u002Fcode> returns \u003Ccode>any\u003C\u002Fcode> by definition, and \u003Ccode>any\u003C\u002Fcode> bypasses every check in the type system, \u003Ccode>NoInfer\u003C\u002Fcode> included — \u003Ccode>defineFlags([...], JSON.parse(rawConfig))\u003C\u002Fcode> compiles clean no matter what string ends up inside it. You still need a runtime check (or a schema validator) at the edge where \u003Ccode>any\u003C\u002Fcode>-typed data enters your program.\u003C\u002Fp>",{"id":183,"html":184,"type":84},"b31","\u003Cp>It also needs TypeScript 5.4 or newer — it shipped in March 2024 as a real compiler intrinsic (\u003Ccode>type NoInfer&lt;T&gt; = intrinsic\u003C\u002Fcode>), not a type you could write yourself. Before 5.4, people approximated it with a conditional-type trick (\u003Ccode>type NoInfer&lt;T&gt; = [T][T extends any ? 0 : never]\u003C\u002Fcode>), which worked in simple cases but had edge-case bugs the built-in version doesn&#39;t share. If you&#39;re on an older compiler, that trick is a stopgap — upgrading is the real fix.\u003C\u002Fp>",{"id":186,"html":187,"type":84},"b32","\u003Cp>And it won&#39;t flag a parameter you \u003Cem>forgot\u003C\u002Fem> to mark — this is opt-in, function by function. It fixes the position you wrap, not every generic helper in your codebase that has the same shape.\u003C\u002Fp>",{"id":189,"html":190,"text":190,"type":103,"level":31},"b33","The takeaway",{"id":192,"html":193,"type":84},"b34","\u003Cp>Any generic helper with a &quot;default,&quot; a &quot;fallback,&quot; or a &quot;this has to match&quot; parameter sitting next to the argument that actually defines the type is a candidate for this bug — it&#39;s letting a position vote that should only ever be checked. The fix is wrapping it in \u003Ccode>NoInfer&lt;T&gt;\u003C\u002Fcode>, and it&#39;s safe to add retroactively: it only makes previously-accepted typos start failing, nothing that was correct before stops compiling.\u003C\u002Fp>",{"id":195,"html":196,"type":84},"b35","\u003Cp>Go find one of those helpers in your own codebase — a config builder, a reducer map, an event registry — and check whether its &quot;default&quot; parameter is quietly widening instead of being validated. What did you find?\u003C\u002Fp>",{"id":198,"html":199,"type":84},"b36","\u003C!-- quiz:start -->",{"id":201,"html":202,"text":202,"type":103,"level":31},"b37","🧠 Test yourself",{"id":204,"html":205,"type":84},"b38","\u003Cp>Think it clicked? \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-noinfer-generic-widening\u002Fquiz\">Take the 8-question quiz →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":207,"html":208,"type":84},"b39","\u003Cp>\u003Cem>Instant feedback, a hint on every question, and an explanation for each answer — right or wrong.\u003C\u002Fem>\u003C\u002Fp>",{"id":210,"html":211,"type":84},"b40","\u003C!-- quiz:end -->",{"id":213,"html":214,"type":84},"b41","\u003C!-- related:start -->",{"id":216,"html":217,"text":217,"type":103,"level":31},"b42","📚 Read next",{"id":219,"type":220,"items":221,"ordered":18},"b43","list",[222,223,224],"\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-as-const-assertions\">My Reducer&#39;s Switch Stopped Being Exhaustive. \u003Ccode>as const\u003C\u002Fcode> Fixed It.\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fintl-numberformat-currency-formatting\">Stop Formatting Currency With Regex. \u003Ccode>Intl.NumberFormat\u003C\u002Fcode> Does It.\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-satisfies-operator\">Your TypeScript config objects are losing type information. \u003Ccode>satisfies\u003C\u002Fcode> fixes it.\u003C\u002Fa>",{"id":226,"html":227,"type":84},"b44","\u003C!-- related:end -->",{"id":229,"type":230},"b45","divider",{"id":232,"html":233,"type":84},"b46","\u003Cp>🚀 \u003Cstrong>Want more like this?\u003C\u002Fstrong> Every guide, playground, and quiz lives on \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">bestpractic.org\u003C\u002Fa>\u003C\u002Fstrong> — open it and \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">sign up free\u003C\u002Fa>\u003C\u002Fstrong> so the next one finds you.\u003C\u002Fp>",{"id":235,"html":236,"type":84},"b47","\u003Cp>\u003Cem>Thanks for reading! Let&#39;s stay connected:\u003C\u002Fem>\u003C\u002Fp>",{"id":238,"type":220,"items":239,"ordered":18},"b48",[240,241,242],"⭐ \u003Cstrong>GitHub\u003C\u002Fstrong> — follow me and star the projects: \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fparsajiravand\">github.com\u002Fparsajiravand\u003C\u002Fa>","💬 \u003Cstrong>Discord\u003C\u002Fstrong> — join the frontend best-practices community: \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ\">discord.gg\u002Fd9KRhuAwQ\u003C\u002Fa>","📸 \u003Cstrong>Instagram\u003C\u002Fstrong> — frontend best practices, daily: \u003Ca href=\"https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F\">@bestpractice___\u003C\u002Fa>","Someone on the team adds a new feature flag, wires up its default, and opens a PR:\n\n```ts\ndefineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"darkmode\");\n```\n\nOne lowercase `m`. Nobody catches it in review — the build is green, the editor shows no red squiggle, `defineFlags` is fully generic and type-safe by every measure anyone checked. It merges.\n\nThree days later the settings panel that reads this default renders a blank icon, because the lookup table keyed by flag name has no entry for `\"darkmode\"` — only `\"darkMode\"`. The function whose entire job was to make this exact typo impossible let it straight through, silently.\n\nThe fix is one word. Understanding why TypeScript needed it took longer.\n\n## The function looked airtight\n\nHere's roughly what `defineFlags` looked like:\n\n```ts\nfunction defineFlags\u003CName extends string>(\n  names: Name[],\n  defaultFlag?: Name\n) {\n  return { names, defaultFlag };\n}\n```\n\nThis reads like it should be bulletproof. `Name` is inferred from the array you pass in, so `defaultFlag` has to be one of those exact strings — that's the whole point of writing it generic instead of typing both parameters as `string`.\n\nSpot the bug yet? Try it before you scroll: paste this into a `.ts` file and see what the compiler says.\n\n```ts\ndefineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"newCheckout\"); \u002F\u002F fine\ndefineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"darkmode\");    \u002F\u002F ???\n```\n\nZero errors. Both lines. The second one — the typo — compiles exactly as cleanly as the first.\n\n## What TypeScript was actually inferring\n\nHere's the part that's easy to get wrong: TypeScript doesn't treat the array argument as \"the source of truth\" for `Name` and then check `defaultFlag` against it. It collects a *candidate* type from every position where `Name` appears unannotated, across the whole call, and only then decides what `Name` is.\n\n`names` offers `\"darkMode\" | \"newCheckout\" | \"betaSearch\"` as a candidate. `defaultFlag` offers whatever you passed — including `\"darkmode\"` — as another candidate. TypeScript doesn't pick one and validate the other against it. It unions them. `Name` quietly becomes `\"darkMode\" | \"newCheckout\" | \"betaSearch\" | \"darkmode\"`, and under that definition, passing `\"darkmode\"` for a parameter of type `Name` is completely correct. You can watch it happen by forcing the inferred type into the open:\n\n```ts\nfunction defineFlagsTyped\u003CName extends string>(\n  names: Name[],\n  defaultFlag?: Name\n): Name {\n  return names[0] as Name;\n}\n\nconst result = defineFlagsTyped(\n  [\"darkMode\", \"newCheckout\", \"betaSearch\"],\n  \"darkmode\"\n);\n\n\u002F\u002F Assigning the \"real\" union back reveals what Name actually became:\nconst check: \"darkMode\" | \"newCheckout\" | \"betaSearch\" = result;\n\u002F\u002F Type '\"darkMode\" | \"newCheckout\" | \"betaSearch\" | \"darkmode\"'\n\u002F\u002F is not assignable to type '\"darkMode\" | \"newCheckout\" | \"betaSearch\"'.\n```\n\n`Name` picked up a fourth member nobody asked for. The typo isn't a value that failed a check — it's part of the type now.\n\n\u003C!-- playground:start -->\n\n## 🎮 Try it yourself\n\n**[▶️ Open the interactive playground →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-noinfer-generic-widening\u002Fplayground)**\n\n_Runs right in your browser — poke at it and watch the concept react live._\n\n\u003C!-- playground:end -->\n\n## The fix: tell TypeScript which position doesn't get a vote\n\n`defaultFlag` was never supposed to help decide what `Name` is. It was supposed to be checked *against* a `Name` that the array had already settled. That's exactly what `NoInfer\u003CT>` — built into TypeScript's standard library since 5.4 — exists to say:\n\n```ts\nfunction defineFlags\u003CName extends string>(\n  names: Name[],\n  defaultFlag?: NoInfer\u003CName>\n) {\n  return { names, defaultFlag };\n}\n\ndefineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"newCheckout\"); \u002F\u002F fine\ndefineFlags([\"darkMode\", \"newCheckout\", \"betaSearch\"], \"darkmode\");\n\u002F\u002F Argument of type '\"darkmode\"' is not assignable to parameter of type\n\u002F\u002F '\"darkMode\" | \"newCheckout\" | \"betaSearch\" | undefined'.\n```\n\nSame call, same arguments — now the typo is a compile error, pointing at the exact argument, before the PR even opens.\n\n`NoInfer\u003CT>` doesn't change what `Name` *can* be; it changes who gets to decide. Wrapping a position in it removes that position from the pool of candidates TypeScript draws `Name` from, without removing the requirement that whatever you pass there still has to match. `names` is still the only thing allowed to say what `Name` is. `defaultFlag` has to agree with it, not contribute to it.\n\nIt's a type-only change — nothing about the function's runtime behavior moves. You're only narrowing which arguments count as evidence to the type checker.\n\n## Where it won't save you\n\n`NoInfer\u003CT>` only works at compile time, against types TypeScript can actually see. A typed value — even a plain `string | undefined` from `process.env` — still gets checked against the real `Name` and still gets rejected if it's wrong. The gap is narrower than \"anything not a literal\": it's specifically `any`. `JSON.parse()` returns `any` by definition, and `any` bypasses every check in the type system, `NoInfer` included — `defineFlags([...], JSON.parse(rawConfig))` compiles clean no matter what string ends up inside it. You still need a runtime check (or a schema validator) at the edge where `any`-typed data enters your program.\n\nIt also needs TypeScript 5.4 or newer — it shipped in March 2024 as a real compiler intrinsic (`type NoInfer\u003CT> = intrinsic`), not a type you could write yourself. Before 5.4, people approximated it with a conditional-type trick (`type NoInfer\u003CT> = [T][T extends any ? 0 : never]`), which worked in simple cases but had edge-case bugs the built-in version doesn't share. If you're on an older compiler, that trick is a stopgap — upgrading is the real fix.\n\nAnd it won't flag a parameter you *forgot* to mark — this is opt-in, function by function. It fixes the position you wrap, not every generic helper in your codebase that has the same shape.\n\n## The takeaway\n\nAny generic helper with a \"default,\" a \"fallback,\" or a \"this has to match\" parameter sitting next to the argument that actually defines the type is a candidate for this bug — it's letting a position vote that should only ever be checked. The fix is wrapping it in `NoInfer\u003CT>`, and it's safe to add retroactively: it only makes previously-accepted typos start failing, nothing that was correct before stops compiling.\n\nGo find one of those helpers in your own codebase — a config builder, a reducer map, an event registry — and check whether its \"default\" parameter is quietly widening instead of being validated. What did you find?\n\n\u003C!-- quiz:start -->\n\n## 🧠 Test yourself\n\nThink it clicked? **[Take the 8-question quiz →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-noinfer-generic-widening\u002Fquiz)**\n\n_Instant feedback, a hint on every question, and an explanation for each answer — right or wrong._\n\n\u003C!-- quiz:end -->\n\n\u003C!-- related:start -->\n\n## 📚 Read next\n\n- [My Reducer's Switch Stopped Being Exhaustive. `as const` Fixed It.](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-as-const-assertions)\n- [Stop Formatting Currency With Regex. `Intl.NumberFormat` Does It.](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fintl-numberformat-currency-formatting)\n- [Your TypeScript config objects are losing type information. `satisfies` fixes it.](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-satisfies-operator)\n\n\u003C!-- related:end -->\n\n---\n\n🚀 **Want more like this?** Every guide, playground, and quiz lives on **[bestpractic.org](https:\u002F\u002Fbestpractic.org\u002F)** — open it and **[sign up free](https:\u002F\u002Fbestpractic.org\u002F)** so the next one finds you.\n\n*Thanks for reading! Let's stay connected:*\n\n- ⭐ **GitHub** — follow me and star the projects: [github.com\u002Fparsajiravand](https:\u002F\u002Fgithub.com\u002Fparsajiravand)\n- 💬 **Discord** — join the frontend best-practices community: [discord.gg\u002Fd9KRhuAwQ](https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ)\n- 📸 **Instagram** — frontend best practices, daily: [@bestpractice___](https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F)",{"title":47,"canonical":245,"description":49},"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-noinfer-generic-widening","01a1df1b-32db-7638-a86f-6132d3f0e26f",{"id":248,"locked":18},"01a1df1b-3323-7396-9bb3-c0c67e0858e1",[250],{"id":251,"slug":46,"title":252,"_count":253},"01a1df1b-3346-75f8-aade-c7a60df4513c","NoInfer\u003CT> Quiz",{"questions":254},8,[256],{"locale":13,"slug":46},{"id":251,"slug":46,"title":252,"_count":258,"questionCount":254},{"questions":254},[260,262,264,268,272,276,278,282,284,288,292,296],{"slug":73,"name":74,"articles":261},195,{"slug":67,"name":68,"articles":263},156,{"slug":265,"name":266,"articles":267},"frontend","Frontend",103,{"slug":269,"name":270,"articles":271},"tutorial","Tutorial",85,{"slug":273,"name":274,"articles":275},"css","Css",56,{"slug":61,"name":65,"articles":277},36,{"slug":279,"name":280,"articles":281},"performance","Performance",33,{"slug":70,"name":71,"articles":283},26,{"slug":285,"name":286,"articles":287},"react","React",23,{"slug":289,"name":290,"articles":291},"node","Node",19,{"slug":293,"name":294,"articles":295},"browser","Browser",18,{"slug":297,"name":298,"articles":299},"nextjs","Nextjs",13,[],{"items":302,"meta":424},[303,321,340,358,370,390,407],{"id":304,"slug":305,"title":306,"subtitle":48,"excerpt":307,"coverUrl":308,"locale":13,"readingMinutes":309,"publishedAt":310,"viewCount":283,"likeCount":19,"commentCount":19,"author":311,"vertical":312,"topic":313,"tags":314,"_count":319,"playground":320,"hasQuiz":17,"hasPlayground":17},"01a1fce0-dac8-71e2-bd25-94b1cc5aa337","typescript-template-literal-types","Template Literal Types Explained: Catching Path Typos at Compile Time","A typo'd dot-path like \"theme.colros.primary\" compiles clean and fails silently at runtime — template literal types make TypeScript catch it before you ship.","\u002Fmedia\u002Fcovers\u002Ftypescript-template-literal-types.png",6,"2026-11-27T11:49:01.332Z",{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[315,316,317,318],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":73,"name":74,"color":48},{"slug":269,"name":270,"color":48},{"assessments":76},{"slug":305},{"id":322,"slug":323,"title":324,"subtitle":48,"excerpt":325,"coverUrl":326,"locale":13,"readingMinutes":327,"publishedAt":328,"viewCount":329,"likeCount":19,"commentCount":19,"author":330,"vertical":331,"topic":332,"tags":333,"_count":338,"playground":339,"hasQuiz":17,"hasPlayground":17},"01a1fce0-c9cc-7004-b075-6c0ff7c7b600","weekly-typescript-type-narrowing","TypeScript Type Narrowing: The Complete Guide","Learn how TypeScript type narrowing really works — typeof, instanceof, discriminated unions, and custom type guards — plus a copy-paste cheat sheet.","\u002Fmedia\u002Fcovers\u002Fweekly-typescript-type-narrowing.png",15,"2026-11-27T11:46:59.418Z",24,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[334,335,336,337],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":269,"name":270,"color":48},{"slug":73,"name":74,"color":48},{"assessments":76},{"slug":323},{"id":341,"slug":342,"title":343,"subtitle":48,"excerpt":344,"coverUrl":345,"locale":13,"readingMinutes":51,"publishedAt":346,"viewCount":347,"likeCount":19,"commentCount":19,"author":348,"vertical":349,"topic":350,"tags":351,"_count":356,"playground":357,"hasQuiz":17,"hasPlayground":17},"01a1fce0-bedd-7648-b22e-4b7afd1cce13","typescript-branded-types-nominal-typing","TypeScript Can't Tell userId From orderId. Branded Types Can.","TypeScript's structural typing treats userId and orderId as the same type if both are `string` — branded types make them incompatible at compile time.","\u002Fmedia\u002Fcovers\u002Ftypescript-branded-types-nominal-typing.png","2026-11-27T11:45:58.086Z",11,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[352,353,354,355],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":73,"name":74,"color":48},{"slug":70,"name":71,"color":48},{"assessments":76},{"slug":342},{"id":45,"slug":46,"title":47,"subtitle":48,"excerpt":49,"coverUrl":50,"locale":13,"readingMinutes":51,"publishedAt":52,"viewCount":359,"likeCount":19,"commentCount":19,"author":360,"vertical":361,"topic":362,"tags":363,"_count":368,"playground":369,"hasQuiz":17,"hasPlayground":17},10,{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[364,365,366,367],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":70,"name":71,"color":48},{"slug":73,"name":74,"color":48},{"assessments":76},{"slug":46},{"id":371,"slug":372,"title":373,"subtitle":48,"excerpt":374,"coverUrl":375,"locale":13,"readingMinutes":376,"publishedAt":377,"viewCount":359,"likeCount":19,"commentCount":19,"author":378,"vertical":379,"topic":380,"tags":383,"_count":388,"playground":389,"hasQuiz":17,"hasPlayground":17},"01a1a1b0-49e9-711f-aea2-cbc2b73acc75","nestjs-weekly-interceptor-order","NestJS Interceptor Order: Why Stacking Breaks Your Cache","NestJS interceptor order decides whether a cache hit skips your response transform. Learn the onion model behind next.handle() — plus a copy-paste cheat sheet.","\u002Fmedia\u002Fcovers\u002Fnestjs-weekly-interceptor-order.png",16,"2026-11-27T11:44:57.150Z",{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":381,"name":382},"nestjs","Nestjs",[384,385,386,387],{"slug":381,"name":382,"color":48},{"slug":289,"name":290,"color":48},{"slug":61,"name":65,"color":48},{"slug":269,"name":270,"color":48},{"assessments":76},{"slug":372},{"id":391,"slug":392,"title":393,"subtitle":48,"excerpt":394,"coverUrl":395,"locale":13,"readingMinutes":51,"publishedAt":396,"viewCount":31,"likeCount":19,"commentCount":19,"author":397,"vertical":398,"topic":399,"tags":400,"_count":405,"playground":406,"hasQuiz":17,"hasPlayground":17},"01a1df1b-2c58-7318-b1ea-6c6fcef9ff05","no-unchecked-indexed-access","arr[i] Isn't Always There. noUncheckedIndexedAccess Says So.","TypeScript types arr[i] as T, never T | undefined — even though the array might be empty. The noUncheckedIndexedAccess flag makes bracket indexing tell the truth.","\u002Fmedia\u002Fcovers\u002Fno-unchecked-indexed-access.png","2026-11-27T11:44:26.334Z",{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[401,402,403,404],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":73,"name":74,"color":48},{"slug":70,"name":71,"color":48},{"assessments":76},{"slug":392},{"id":408,"slug":409,"title":410,"subtitle":48,"excerpt":411,"coverUrl":412,"locale":13,"readingMinutes":51,"publishedAt":413,"viewCount":31,"likeCount":19,"commentCount":19,"author":414,"vertical":415,"topic":416,"tags":417,"_count":422,"playground":423,"hasQuiz":17,"hasPlayground":17},"01a1df1b-2879-726c-b86f-69cba3a4ecc3","typescript-exhaustiveness-checking-never","Your switch forgets a case. Exhaustiveness checking catches it.","How to make the TypeScript compiler fail the build when a switch statement doesn't handle every member of a union — using the `never` type.","\u002Fmedia\u002Fcovers\u002Ftypescript-exhaustiveness-checking-never.png","2026-11-27T11:43:55.790Z",{"id":55,"name":56,"username":57,"avatarUrl":48,"headline":58},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":61,"name":62},[418,419,420,421],{"slug":61,"name":65,"color":48},{"slug":67,"name":68,"color":48},{"slug":70,"name":71,"color":48},{"slug":73,"name":74,"color":48},{"assessments":76},{"slug":409},{"page":76,"perPage":425,"total":277,"totalPages":309},7,"\u003Cdiv class=\"shj shj-lang-ts shj-oneline\" data-lang=\"ts\">\u003Cspan class=\"shj-func\">defineFlags\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-str\">\"darkMode\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"newCheckout\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"betaSearch\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"darkmode\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-ts shj-multiline\" data-lang=\"ts\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> defineFlags\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-class\">Name\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">extends\u003C\u002Fspan> string\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\n  names\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Name\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan>\n  defaultFlag\u003Cspan class=\"shj-oper\">?:\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Name\u003C\u002Fspan>\n\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> names\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> defaultFlag \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-ts shj-multiline\" data-lang=\"ts\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-func\">defineFlags\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-str\">\"darkMode\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"newCheckout\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"betaSearch\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"newCheckout\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>; \u003Cspan class=\"shj-cmnt\">\u002F\u002F fine\n\u003C\u002Fspan>\u003Cspan class=\"shj-func\">defineFlags\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-str\">\"darkMode\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"newCheckout\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"betaSearch\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"darkmode\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;    \u003Cspan class=\"shj-cmnt\">\u002F\u002F ???\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-ts shj-multiline\" data-lang=\"ts\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003Cdiv>7\u003C\u002Fdiv>\u003Cdiv>8\u003C\u002Fdiv>\u003Cdiv>9\u003C\u002Fdiv>\u003Cdiv>10\u003C\u002Fdiv>\u003Cdiv>11\u003C\u002Fdiv>\u003Cdiv>12\u003C\u002Fdiv>\u003Cdiv>13\u003C\u002Fdiv>\u003Cdiv>14\u003C\u002Fdiv>\u003Cdiv>15\u003C\u002Fdiv>\u003Cdiv>16\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> defineFlagsTyped\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-class\">Name\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">extends\u003C\u002Fspan> string\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\n  names\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Name\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan>\n  defaultFlag\u003Cspan class=\"shj-oper\">?:\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Name\u003C\u002Fspan>\n\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Name\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> names\u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-num\">0\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">as\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Name\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\n\n\u003Cspan class=\"shj-kwd\">const\u003C\u002Fspan> result \u003Cspan class=\"shj-oper\">=\u003C\u002Fspan> \u003Cspan class=\"shj-func\">defineFlagsTyped\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\n  \u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-str\">\"darkMode\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"newCheckout\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"betaSearch\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan>\n  \u003Cspan class=\"shj-str\">\"darkmode\"\u003C\u002Fspan>\n\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n\n\u003Cspan class=\"shj-cmnt\">\u002F\u002F Assigning the \"real\" union back reveals what Name actually became:\n\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">const\u003C\u002Fspan> check\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"darkMode\"\u003C\u002Fspan> \u003Cspan class=\"shj-oper\">|\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"newCheckout\"\u003C\u002Fspan> \u003Cspan class=\"shj-oper\">|\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"betaSearch\"\u003C\u002Fspan> \u003Cspan class=\"shj-oper\">=\u003C\u002Fspan> result;\n\u003Cspan class=\"shj-cmnt\">\u002F\u002F Type '\"darkMode\" | \"newCheckout\" | \"betaSearch\" | \"darkmode\"'\n\u003C\u002Fspan>\u003Cspan class=\"shj-cmnt\">\u002F\u002F is not assignable to type '\"darkMode\" | \"newCheckout\" | \"betaSearch\"'.\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-ts shj-multiline\" data-lang=\"ts\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003Cdiv>7\u003C\u002Fdiv>\u003Cdiv>8\u003C\u002Fdiv>\u003Cdiv>9\u003C\u002Fdiv>\u003Cdiv>10\u003C\u002Fdiv>\u003Cdiv>11\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> defineFlags\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-class\">Name\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">extends\u003C\u002Fspan> string\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\n  names\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Name\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan>\n  defaultFlag\u003Cspan class=\"shj-oper\">?:\u003C\u002Fspan> \u003Cspan class=\"shj-class\">NoInfer\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-class\">Name\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>\n\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> names\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> defaultFlag \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\n\n\u003Cspan class=\"shj-func\">defineFlags\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-str\">\"darkMode\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"newCheckout\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"betaSearch\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"newCheckout\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>; \u003Cspan class=\"shj-cmnt\">\u002F\u002F fine\n\u003C\u002Fspan>\u003Cspan class=\"shj-func\">defineFlags\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">[\u003C\u002Fspan>\u003Cspan class=\"shj-str\">\"darkMode\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"newCheckout\"\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"betaSearch\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">]\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> \u003Cspan class=\"shj-str\">\"darkmode\"\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n\u003Cspan class=\"shj-cmnt\">\u002F\u002F Argument of type '\"darkmode\"' is not assignable to parameter of type\n\u003C\u002Fspan>\u003Cspan class=\"shj-cmnt\">\u002F\u002F '\"darkMode\" | \"newCheckout\" | \"betaSearch\" | undefined'.\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>",{"locked":18,"total":19,"comments":432},[]]