{"id":13201,"date":"2026-03-17T06:29:18","date_gmt":"2026-03-17T06:29:18","guid":{"rendered":"https:\/\/withcode.tech\/media\/?p=13201"},"modified":"2026-08-17T14:39:45","modified_gmt":"2026-08-17T14:39:45","slug":"typescript-conditional-types-guide","status":"publish","type":"post","link":"https:\/\/withcode.tech\/media\/typescript-conditional-types-guide\/","title":{"rendered":"TypeScript Conditional Type\u5b8c\u5168\u30ac\u30a4\u30c9\uff5cinfer\u30fbUnion\u5206\u914d\u30fb\u518d\u5e30\u7684\u6761\u4ef6\u578b\u3092\u89e3\u8aac"},"content":{"rendered":"\n<div class=\"wp-block-group swl-box\"><div class=\"wp-block-group__inner-container\">\n<h2 class=\"wp-block-heading\">\u3053\u306e\u8a18\u4e8b\u3067\u308f\u304b\u308b\u3053\u3068<\/h2>\n<ul class=\"wp-block-list\">\n<li>Conditional Type\uff08T extends U ? X : Y\uff09\u306e\u57fa\u672c\u69cb\u6587\u3068\u578b\u968e\u5c64\u306e\u95a2\u4fc2<\/li>\n<li>\u5206\u914d\u7684\u6761\u4ef6\u578b\uff08Union Distribution\uff09\u306e\u4ed5\u7d44\u307f\u3068\u5206\u914d\u306e\u6291\u5236\u65b9\u6cd5<\/li>\n<li>infer\u30ad\u30fc\u30ef\u30fc\u30c9\u3092\u4f7f\u3063\u305f\u95a2\u6570\u30fbPromise\u30fb\u30bf\u30d7\u30eb\u304b\u3089\u306e\u578b\u62bd\u51fa<\/li>\n<li>DeepPartial\u30fbDeepReadonly\u30fbFlatten\u306a\u3069\u518d\u5e30\u7684\u6761\u4ef6\u578b\u306e\u5b9f\u88c5<\/li>\n<li>\u3088\u304f\u3042\u308b\u843d\u3068\u3057\u7a74\uff08never\u30fbany\u306e\u6319\u52d5\uff09\u3068\u578b\u30c6\u30b9\u30c8\u306e\u66f8\u304d\u65b9<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n<div class=\"swell-block-balloon\"><div class=\"c-balloon -bln-left\" data-col=\"gray\"><div class=\"c-balloon__icon -square\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2025\/06\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-06-15-14.48.08.jpg\" alt=\"\" class=\"c-balloon__iconImg\" width=\"80px\" height=\"80px\"><span class=\"c-balloon__iconName\">\u751f\u5f92<\/span><\/div><div class=\"c-balloon__body -speaking -border-none\"><div class=\"c-balloon__text\">\n  <p><strong>TypeScript\u306e\u578b\u3067if\u6587\u307f\u305f\u3044\u306a\u6761\u4ef6\u5206\u5c90\u3092\u3057\u305f\u3044\u3093\u3067\u3059\u304c\u2026\u2026Conditional Type\u3068\u3044\u3046\u306e\u3092\u805e\u3044\u305f\u3053\u3068\u304c\u3042\u308b\u3093\u3067\u3059\u304c\u3001\u96e3\u3057\u305d\u3046\u3067<\/strong><\/p>\n  <span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div><\/div><\/div>\n\n  <div class=\"swell-block-balloon\"><div class=\"c-balloon -bln-right\" data-col=\"gray\"><div class=\"c-balloon__icon -square\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2025\/06\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2025-06-15-15.11.23.jpg\" alt=\"\" class=\"c-balloon__iconImg\" width=\"80px\" height=\"80px\"><span class=\"c-balloon__iconName\">\u30da\u30f3\u535a\u58eb<\/span><\/div><div class=\"c-balloon__body -speaking -border-none\"><div class=\"c-balloon__text\">\n  <p><strong>Conditional Type\u306fTypeScript\u306e\u5f37\u529b\u306a\u6a5f\u80fd\u306e\u4e00\u3064\u3058\u3083\uff01\u4e09\u9805\u6f14\u7b97\u5b50\u306e\u3088\u3046\u306a\u5f62\u3067\u300c\u578b\u304cA\u306a\u3089X\u306e\u578b\u3092\u8fd4\u3057\u3001\u305d\u3046\u3067\u306a\u3051\u308c\u3070Y\u306e\u578b\u3092\u8fd4\u3059\u300d\u3068\u3044\u3046\u6761\u4ef6\u5206\u5c90\u304c\u578b\u30ec\u30d9\u30eb\u3067\u3067\u304d\u308b\u3093\u3058\u3083\u3002infer\u30ad\u30fc\u30ef\u30fc\u30c9\u3067\u578b\u3092\u300c\u5909\u6570\u3068\u3057\u3066\u6355\u6349\u300d\u3059\u308b\u3053\u3068\u3067\u3001ReturnType\u3084Extract\u306a\u3069\u306e\u7d44\u307f\u8fbc\u307f\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b\u3082\u81ea\u4f5c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3057\u3001DeepPartial\u306e\u3088\u3046\u306a\u518d\u5e30\u7684\u306a\u578b\u3082\u5b9f\u88c5\u3067\u304d\u308b\u305e\uff01<\/strong><\/p>\n  <span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div><\/div><\/div>\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7d50\u8ad6\uff1aConditional Type\uff08<code>T extends U ? X : Y<\/code>\uff09\u306fTypeScript\u3067\u578b\u30ec\u30d9\u30eb\u306e\u6761\u4ef6\u5206\u5c90\u3092\u5b9f\u73fe\u3059\u308b\u6a5f\u80fd\u3067\u3059\u3002<\/strong>Union Distribution\u3067\u30e6\u30cb\u30aa\u30f3\u578b\u306e\u5404\u30e1\u30f3\u30d0\u30fc\u306b\u500b\u5225\u9069\u7528\u3067\u304d\u3001infer\u30ad\u30fc\u30ef\u30fc\u30c9\u3067\u578b\u3092\u5909\u6570\u3068\u3057\u3066\u6355\u6349\u3067\u304d\u307e\u3059\u3002ReturnType\u30fbExtract\u30fbExclude\u306a\u3069\u306e\u7d44\u307f\u8fbc\u307f\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b\u3082\u3059\u3079\u3066\u3053\u306e\u6a5f\u80fd\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u8a18\u4e8b\u3067\u306f\u3001<strong><span class=\"swl-marker mark_yellow\">Conditional Type\u306e\u57fa\u672c\u69cb\u6587\u30fb\u5206\u914d\u7684\u6761\u4ef6\u578b\u3068\u975e\u5206\u914d\u7684\u6761\u4ef6\u578b\u30fbUnion Distribution\uff08\u30e6\u30cb\u30aa\u30f3\u306e\u5206\u914d\uff09\u30fbinfer\u30ad\u30fc\u30ef\u30fc\u30c9\u306e\u591a\u69d8\u306a\u5fdc\u7528\u30fb\u5168\u7d44\u307f\u8fbc\u307f\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b\u306e\u81ea\u4f5c\u30fb\u518d\u5e30\u7684\u6761\u4ef6\u578b\uff08DeepPartial\u30fbDeepReadonly\u30fbFlatten\uff09\u30fb\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30ea\u30c6\u30e9\u30eb\u578b\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u30fb\u5b9f\u8df5\u7684\u306a\u30ab\u30b9\u30bf\u30e0\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b\u30fb\u3088\u304f\u3042\u308b\u843d\u3068\u3057\u7a74\u3068\u89e3\u6c7a\u7b56<\/span><\/strong>\u3092\u5b8c\u5168\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conditional Type\u306e\u57fa\u672c\u69cb\u6587<\/h2>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-typescript\" data-lang=\"TypeScript\"><code>&gt;\/\/ \u57fa\u672c\u69cb\u6587: T extends U ? X : Y\n\/\/ T \u304c U \u306e\u30b5\u30d6\u30bf\u30a4\u30d7\uff08U \u306b\u4ee3\u5165\u53ef\u80fd\uff09\u3067\u3042\u308c\u3070 X \u3092\u3001\u305d\u3046\u3067\u306a\u3051\u308c\u3070 Y \u3092\u8fd4\u3059\n\n\/\/ \u30b7\u30f3\u30d7\u30eb\u306a\u4f8b\ntype IsNumber&lt;T&gt; = T extends number ? true : false\n\ntype T1 = IsNumber&lt;10&gt;       \/\/ true\ntype T2 = IsNumber&lt;'hello'&gt;  \/\/ false\ntype T3 = IsNumber&lt;number&gt;   \/\/ true\ntype T4 = IsNumber&lt;string&gt;   \/\/ false\n\n\/\/ TypeScript\u306e\u578b\u968e\u5c64\uff08\u30b5\u30d6\u30bf\u30a4\u30d7\u306e\u95a2\u4fc2\uff09\n\/\/ number extends number       \u2192 true\n\/\/ 42 extends number           \u2192 true\uff08\u30ea\u30c6\u30e9\u30eb\u578b\u306fnumber\u306e\u30b5\u30d6\u30bf\u30a4\u30d7\uff09\n\/\/ string extends number       \u2192 false\n\/\/ string extends string|number \u2192 true\uff08string\u306fstring|number\u306e\u30b5\u30d6\u30bf\u30a4\u30d7\uff09\n\/\/ never extends string        \u2192 true\uff08never\u306f\u3059\u3079\u3066\u306e\u578b\u306e\u30b5\u30d6\u30bf\u30a4\u30d7\uff09\n\/\/ string extends unknown      \u2192 true\uff08\u3059\u3079\u3066\u306e\u578b\u306funknown\u306e\u30b5\u30d6\u30bf\u30a4\u30d7\uff09\n\n\/\/ \u30cd\u30b9\u30c8\u3057\u305f\u6761\u4ef6\u578b\ntype TypeName&lt;T&gt; =\n  T extends string   ? 'string'   :\n  T extends number   ? 'number'   :\n  T extends boolean  ? 'boolean'  :\n  T extends null     ? 'null'     :\n  T extends undefined? 'undefined':\n  T extends object   ? 'object'   :\n  'unknown'\n\ntype TN1 = TypeName&lt;'hello'&gt;    \/\/ 'string'\ntype TN2 = TypeName&lt;42&gt;         \/\/ 'number'\ntype TN3 = TypeName&lt;true&gt;       \/\/ 'boolean'\ntype TN4 = TypeName&lt;null&gt;       \/\/ 'null'\ntype TN5 = TypeName&lt;{}&gt;         \/\/ 'object'\ntype TN6 = TypeName&lt;symbol&gt;     \/\/ 'unknown'<\/code><\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5206\u914d\u7684\u6761\u4ef6\u578b\uff08Distributive Conditional Types\uff09<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Conditional Type\u306b\u306f<strong>\u300c\u5206\u914d\u300d<\/strong>\u3068\u3044\u3046\u91cd\u8981\u306a\u6027\u8cea\u304c\u3042\u308a\u307e\u3059\u3002\u578b\u5909\u6570T\u306bUnion\u578b\u304c\u6e21\u3055\u308c\u308b\u3068\u3001Union\u578b\u306e\u5404\u30e1\u30f3\u30d0\u30fc\u306b\u5bfe\u3057\u3066\u500b\u5225\u306bConditional Type\u304c\u9069\u7528\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-typescript\" data-lang=\"TypeScript\"><code>&gt;\/\/ \u5206\u914d\u7684\u6761\u4ef6\u578b\u306e\u4f8b\n\ntype ToArray&lt;T&gt; = T extends any ? T[] : never\n\n\/\/ T\u306bUnion\u578b\u3092\u6e21\u3059\u3068\u5206\u914d\u304c\u8d77\u304d\u308b\ntype StringOrNumberArray = ToArray&lt;string | number&gt;\n\/\/ \u2192 string[] | number[]\n\/\/ \uff08string | number\uff09[] \u3068\u306f\u7570\u306a\u308b\uff01\n\n\/\/ \u5185\u90e8\u52d5\u4f5c\u306e\u30a4\u30e1\u30fc\u30b8\uff1a\n\/\/ string extends any ? string[] : never \u2192 string[]\n\/\/ number extends any ? number[] : never \u2192 number[]\n\/\/ \u7d50\u679c: string[] | number[]\n\n\/\/ \u30e6\u30cb\u30aa\u30f3\u3092\u5206\u914d\u3057\u3066\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0\ntype FilterBoolean&lt;T&gt; = T extends boolean ? never : T\n\ntype Mixed = string | number | boolean | null\ntype NonBoolean = FilterBoolean&lt;Mixed&gt;\n\/\/ \u2192 string | number | null\uff08boolean\u304c\u9664\u53bb\u3055\u308c\u308b\uff09\n\n\/\/ \u5206\u914d\u304c\u767a\u751f\u3059\u308b\u306e\u306f\u300c\u578b\u5909\u6570\u300d\u3068\u3057\u3066\u88f8\u3067\u4f7f\u308f\u308c\u308b\u5834\u5408\u306e\u307f\n\/\/ tuple\/array\u3067\u30e9\u30c3\u30d7\u3059\u308b\u3068\u5206\u914d\u3092\u6291\u5236\u3067\u304d\u308b\ntype IsNever&lt;T&gt; = [T] extends [never] ? true : false\n\/\/                \u2191 \u30e9\u30c3\u30d7\u3067\u5206\u914d\u3092\u6291\u5236\n\ntype Test1 = IsNever&lt;never&gt;         \/\/ true\ntype Test2 = IsNever&lt;string&gt;        \/\/ false\ntype Test3 = IsNever&lt;string | never&gt; \/\/ false\uff08never\u306funion\u304b\u3089\u6d88\u3048\u308b\u305f\u3081\uff09\n\n\/\/ \u6bd4\u8f03: \u5206\u914d\u7684\u306a\u5834\u5408\ntype IsNeverDistributive&lt;T&gt; = T extends never ? true : false\ntype TestD1 = IsNeverDistributive&lt;never&gt;  \/\/ never\uff08\u5206\u914d\u3067never\u306f\u4f55\u3082\u9069\u7528\u3055\u308c\u306a\u3044\uff01\uff09<\/code><\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Union Distribution\u306e\u6d3b\u7528\u4f8b\uff5cExtract\u30fbExclude\u30fbNonNullable<\/h3>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-typescript\" data-lang=\"TypeScript\"><code>&gt;\/\/ ===== \u7d44\u307f\u8fbc\u307f\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b\u306e\u81ea\u4f5c =====\n\n\/\/ Extract&lt;T, U&gt;: T \u304b\u3089U\u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u306e\u307f\u3092\u62bd\u51fa\ntype MyExtract&lt;T, U&gt; = T extends U ? T : never\n\ntype JobGrade = 'S' | 'A' | 'B' | 'C' | 'D'\ntype HighGrade = MyExtract&lt;JobGrade, 'S' | 'A'&gt;\n\/\/ \u2192 \"S\" | \"A\"\n\n\/\/ Exclude&lt;T, U&gt;: T \u304b\u3089U\u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3092\u9664\u5916\ntype MyExclude&lt;T, U&gt; = T extends U ? never : T\n\ntype LowGrade = MyExclude&lt;JobGrade, 'S' | 'A'&gt;\n\/\/ \u2192 \"B\" | \"C\" | \"D\"\n\n\/\/ NonNullable&lt;T&gt;: null \u3068 undefined \u3092\u9664\u5916\ntype MyNonNullable&lt;T&gt; = T extends null | undefined ? never : T\n\ntype MaybeString = string | null | undefined\ntype DefiniteString = MyNonNullable&lt;MaybeString&gt;  \/\/ string\n\n\/\/ Filter\uff08\u6c4e\u7528\u30d5\u30a3\u30eb\u30bf\u30fc\u578b\uff09\ntype Filter&lt;T, U&gt; = T extends U ? T : never  \/\/ = Extract \u3068\u540c\u3058\ntype Reject&lt;T, U&gt; = T extends U ? never : T  \/\/ = Exclude \u3068\u540c\u3058\n\n\/\/ \u7279\u5b9a\u306e\u578b\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30ad\u30fc\u306e\u307f\u3092\u62bd\u51fa\uff08\u5b9f\u7528\u7684\uff01\uff09\ntype PickByValue&lt;T, V&gt; = {\n  [K in keyof T as T[K] extends V ? K : never]: T[K]\n}\n\ninterface User {\n  id: number\n  name: string\n  email: string\n  age: number\n  isAdmin: boolean\n}\n\ntype StringKeys = PickByValue&lt;User, string&gt;\n\/\/ \u2192 { name: string; email: string }\n\ntype NumberKeys = PickByValue&lt;User, number&gt;\n\/\/ \u2192 { id: number; age: number }<\/code><\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">infer\u30ad\u30fc\u30ef\u30fc\u30c9\uff5c\u578b\u3092\u300c\u63a8\u8ad6\u3057\u3066\u62bd\u51fa\u300d\u3059\u308b<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>infer<\/code> \u306f Conditional Type \u306e\u6761\u4ef6\u90e8\u3067\u4f7f\u3048\u308b\u30ad\u30fc\u30ef\u30fc\u30c9\u3067\u3001<strong>\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u3057\u305f\u578b\u3092\u5909\u6570\u3068\u3057\u3066\u6355\u6349<\/strong>\u3067\u304d\u307e\u3059\u3002\u300c\u578b\u30ec\u30d9\u30eb\u306e\u6b63\u898f\u8868\u73fe\u30ad\u30e3\u30d7\u30c1\u30e3\u300d\u306e\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u95a2\u6570\u578b\u304b\u3089\u306einfer\u6d3b\u7528<\/h3>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-typescript\" data-lang=\"TypeScript\"><code>&gt;\/\/ ===== \u95a2\u6570\u578b\u306b\u95a2\u3059\u308binfer =====\n\n\/\/ ReturnType&lt;T&gt;\u306e\u81ea\u4f5c\uff08\u95a2\u6570\u306e\u623b\u308a\u5024\u578b\u3092\u62bd\u51fa\uff09\ntype MyReturnType&lt;T&gt; = T extends (...args: any[]) =&gt; infer R ? R : never\n\ntype Fn1 = () =&gt; number\ntype Fn2 = (x: string) =&gt; string[]\ntype Fn3 = () =&gt; Promise&lt;{ id: number }&gt;\ntype AsyncFn = () =&gt; Promise&lt;string&gt;\n\ntype R1 = MyReturnType&lt;Fn1&gt;  \/\/ number\ntype R2 = MyReturnType&lt;Fn2&gt;  \/\/ string[]\ntype R3 = MyReturnType&lt;Fn3&gt;  \/\/ Promise&lt;{ id: number }&gt;\ntype R4 = MyReturnType&lt;string&gt;  \/\/ never\uff08\u95a2\u6570\u3067\u306a\u3044\u305f\u3081\uff09\n\n\/\/ Parameters&lt;T&gt;\u306e\u81ea\u4f5c\uff08\u95a2\u6570\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u578b\u3092Tuple\u3067\u53d6\u5f97\uff09\ntype MyParameters&lt;T&gt; = T extends (...args: infer P) =&gt; any ? P : never\n\ntype P1 = MyParameters&lt;(x: string, y: number) =&gt; void&gt;  \/\/ [string, number]\ntype P2 = MyParameters&lt;() =&gt; void&gt;                       \/\/ []\ntype P3 = MyParameters&lt;(ids: number[]) =&gt; void&gt;          \/\/ [number[]]\n\n\/\/ FirstParam\uff08\u6700\u521d\u306e\u5f15\u6570\u306e\u578b\u306e\u307f\u53d6\u5f97\uff09\ntype FirstParam&lt;T&gt; = T extends (first: infer F, ...rest: any[]) =&gt; any ? F : never\ntype FP = FirstParam&lt;(id: number, name: string) =&gt; void&gt;  \/\/ number\n\n\/\/ ConstructorParameters&lt;T&gt;\u306e\u81ea\u4f5c\uff08\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u30fc\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u578b\uff09\ntype MyConstructorParameters&lt;T&gt; = T extends new (...args: infer P) =&gt; any ? P : never\n\nclass MyClass {\n  constructor(public name: string, public value: number) {}\n}\ntype CP = MyConstructorParameters&lt;typeof MyClass&gt;  \/\/ [string, number]\n\n\/\/ InstanceType&lt;T&gt;\u306e\u81ea\u4f5c\uff08\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u578b\u3092\u53d6\u5f97\uff09\ntype MyInstanceType&lt;T&gt; = T extends new (...args: any[]) =&gt; infer I ? I : never\ntype IT = MyInstanceType&lt;typeof MyClass&gt;  \/\/ MyClass<\/code><\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Promise\u30fb\u914d\u5217\u30fb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3078\u306einfer\u6d3b\u7528<\/h3>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-typescript\" data-lang=\"TypeScript\"><code>&gt;\/\/ ===== \u914d\u5217\u30fbPromise\u304b\u3089\u306einfer =====\n\n\/\/ Promise\u306e\u4e2d\u306e\u578b\u3092\u53d6\u308a\u51fa\u3059\uff08Awaited&lt;T&gt;\u306e\u81ea\u4f5c\uff09\ntype UnwrapPromise&lt;T&gt; = T extends Promise&lt;infer U&gt; ? UnwrapPromise&lt;U&gt; : T\n\/\/ \u518d\u5e30\u7684\u306bPromise\u3092\u30a2\u30f3\u30e9\u30c3\u30d7\n\ntype P1 = UnwrapPromise&lt;Promise&lt;string&gt;&gt;                   \/\/ string\ntype P2 = UnwrapPromise&lt;Promise&lt;Promise&lt;number&gt;&gt;&gt;          \/\/ number\ntype P3 = UnwrapPromise&lt;Promise&lt;Promise&lt;Promise&lt;boolean&gt;&gt;&gt;&gt; \/\/ boolean\ntype P4 = UnwrapPromise&lt;string&gt;                            \/\/ string\uff08Promise\u3067\u306a\u3044\u306e\u3067\u305d\u306e\u307e\u307e\uff09\n\n\/\/ Awaited&lt;T&gt;\uff08TypeScript 4.5\u4ee5\u964d\u306e\u7d44\u307f\u8fbc\u307f\u578b\uff09\ntype A1 = Awaited&lt;Promise&lt;string&gt;&gt;  \/\/ string\uff08\u7d44\u307f\u8fbc\u307f\u3067\u540c\u3058\u52d5\u4f5c\uff09\n\n\/\/ \u914d\u5217\u306e\u8981\u7d20\u578b\u3092\u53d6\u308a\u51fa\u3059\ntype ElementType&lt;T&gt; = T extends ReadonlyArray&lt;infer E&gt; ? E : never\n\ntype E1 = ElementType&lt;string[]&gt;          \/\/ string\ntype E2 = ElementType&lt;readonly number[]&gt; \/\/ number\ntype E3 = ElementType&lt;[string, number]&gt;  \/\/ string | number\uff08tuple\u306e\u5834\u5408\uff09\n\n\/\/ \u30bf\u30d7\u30eb\u64cd\u4f5c\ntype Head&lt;T extends any[]&gt; = T extends [infer H, ...any[]] ? H : never\ntype Tail&lt;T extends any[]&gt; = T extends [any, ...infer T] ? T : never\ntype Last&lt;T extends any[]&gt; = T extends [...any[], infer L] ? L : never\ntype Init&lt;T extends any[]&gt; = T extends [...infer I, any] ? I : never\n\ntype Tuple = [string, number, boolean, null]\ntype H = Head&lt;Tuple&gt;   \/\/ string\ntype Ta = Tail&lt;Tuple&gt;  \/\/ [number, boolean, null]\ntype L = Last&lt;Tuple&gt;   \/\/ null\ntype I = Init&lt;Tuple&gt;   \/\/ [string, number, boolean]\n\n\/\/ ===== \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u578b\u304b\u3089\u306einfer =====\n\n\/\/ Promise\u306e\u623b\u308a\u5024\u306e\u578b\u3092\u95a2\u6570\u304b\u3089\u76f4\u63a5\u53d6\u5f97\ntype AsyncReturnType&lt;T&gt; = T extends (...args: any[]) =&gt; Promise&lt;infer R&gt; ? R : never\n\nasync function fetchUser(id: number): Promise&lt;{ id: number; name: string }&gt; {\n  return { id, name: 'Taro' }\n}\ntype UserType = AsyncReturnType&lt;typeof fetchUser&gt;\n\/\/ \u2192 { id: number; name: string }\n\n\/\/ \u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u578b\u3092\u53d6\u5f97\ntype PropType&lt;T, K extends keyof T&gt; = T[K] extends infer V ? V : never\n\ntype UserName = PropType&lt;{ id: number; name: string }, 'name'&gt;  \/\/ string<\/code><\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u518d\u5e30\u7684\u6761\u4ef6\u578b\uff5cDeepPartial\u30fbDeepReadonly\u30fbFlatten<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">TypeScript 4.1\u4ee5\u964d\u3001<strong>\u518d\u5e30\u7684\u306a\u6761\u4ef6\u578b<\/strong>\u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u307e\u3057\u305f\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30cd\u30b9\u30c8\u3057\u305f\u578b\u3092\u6df1\u304f\u5909\u63db\u3059\u308b\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b\u304c\u5b9f\u88c5\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-typescript\" data-lang=\"TypeScript\"><code>&gt;\/\/ DeepPartial: \u6df1\u3044\u30ec\u30d9\u30eb\u307e\u3067\u5168\u30d7\u30ed\u30d1\u30c6\u30a3\u3092optional\u306b\u3059\u308b\ntype DeepPartial&lt;T&gt; = T extends object\n  ? { [K in keyof T]?: DeepPartial&lt;T[K]&gt; }\n  : T\n\n\/\/ \u7d44\u307f\u8fbc\u307f\u306ePartial&lt;T&gt;\u306f1\u30ec\u30d9\u30eb\u306e\u307f\ntype ShallowPartial = Partial&lt;{\n  user: { name: string; address: { city: string } }\n}&gt;\n\/\/ \u2192 { user?: { name: string; address: { city: string } } }\n\/\/ user.name \u3084 user.address.city \u306foptional\u306b\u306a\u3089\u306a\u3044\n\ntype DeepPartialExample = DeepPartial&lt;{\n  user: { name: string; address: { city: string; zip: string } }\n  settings: { theme: 'light' | 'dark'; fontSize: number }\n}&gt;\n\/\/ \u2192 { user?: { name?: string; address?: { city?: string; zip?: string } }; settings?: ... }\n\n\/\/ \u4f7f\u3044\u65b9\uff08\u30d5\u30a9\u30fc\u30e0\u306e\u90e8\u5206\u7684\u306a\u66f4\u65b0\u306b\u4fbf\u5229\uff09\nfunction updateUser(patch: DeepPartial&lt;User&gt;): void {\n  \/\/ patch\u306f\u5168\u30d7\u30ed\u30d1\u30c6\u30a3\u304coptional\uff08\u6df1\u3044\u30ec\u30d9\u30eb\u3067\u3082\uff09\n}\n\n\/\/ ===== DeepReadonly =====\ntype DeepReadonly&lt;T&gt; = T extends (infer U)[]\n  ? ReadonlyArray&lt;DeepReadonly&lt;U&gt;&gt;\n  : T extends object\n  ? { readonly [K in keyof T]: DeepReadonly&lt;T[K]&gt; }\n  : T\n\ntype Config = {\n  database: {\n    host: string\n    port: number\n    credentials: { username: string; password: string }\n  }\n  features: string[]\n}\n\ntype ImmutableConfig = DeepReadonly&lt;Config&gt;\n\/\/ \u5168\u30d7\u30ed\u30d1\u30c6\u30a3\u30fb\u30cd\u30b9\u30c8\u3055\u308c\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u30fb\u914d\u5217\u304creadonly\n\n\/\/ ===== Flatten\uff08\u914d\u5217\u3092\u30d5\u30e9\u30c3\u30c8\u5316\u3059\u308b\u578b\uff09=====\ntype Flatten&lt;T&gt; = T extends Array&lt;infer U&gt; ? Flatten&lt;U&gt; : T\n\ntype F1 = Flatten&lt;string[][][]&gt;    \/\/ string\ntype F2 = Flatten&lt;number[]&gt;        \/\/ number\ntype F3 = Flatten&lt;string&gt;          \/\/ string\uff08\u914d\u5217\u3067\u306a\u3044\u306e\u3067\u305d\u306e\u307e\u307e\uff09\n\n\/\/ ===== DeepOmit\uff08\u6df1\u3044\u30cd\u30b9\u30c8\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u9664\u5916\uff09=====\n\/\/ \u5358\u7d14\u306a\u5b9f\u88c5\u4f8b\ntype DeepOmit&lt;T, K extends string | number | symbol&gt; = T extends object\n  ? { [P in Exclude&lt;keyof T, K&gt;]: DeepOmit&lt;T[P], K&gt; }\n  : T\n\ntype WithoutPassword = DeepOmit&lt;{\n  user: { id: number; name: string; password: string }\n  admin: { id: number; password: string; role: string }\n}, 'password'&gt;\n\/\/ \u2192 { user: { id: number; name: string }; admin: { id: number; role: string } }<\/code><\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30ea\u30c6\u30e9\u30eb\u578b\u3068\u306e\u7d44\u307f\u5408\u308f\u305b<\/h2>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-markup\" data-lang=\"HTML\"><code>&gt;\/\/ \u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30ea\u30c6\u30e9\u30eb\u578b + Conditional Type + infer\n\n\/\/ Split: \u6587\u5b57\u5217\u578b\u3092\u30c7\u30ea\u30df\u30bf\u3067\u5206\u5272\u3057\u3066Tuple\u306b\u5909\u63db\ntype Split&lt;S extends string, D extends string&gt; =\n  S extends `${infer T}${D}${infer U}`\n    ? [T, ...Split&lt;U, D&gt;]\n    : [S]\n\ntype S1 = Split&lt;'a.b.c', '.'&gt;  \/\/ [\"a\", \"b\", \"c\"]\ntype S2 = Split&lt;'hello-world', '-'&gt;  \/\/ [\"hello\", \"world\"]\ntype S3 = Split&lt;'no-delimiter', ','&gt;  \/\/ [\"no-delimiter\"]\n\n\/\/ Join: Tuple\u3092\u6587\u5b57\u5217\u306b\u7d50\u5408\ntype Join&lt;T extends string[], D extends string&gt; =\n  T extends [infer F extends string, ...infer R extends string[]]\n    ? `${F}${R extends [] ? '' : `${D}${Join&lt;R, D&gt;}`}`\n    : ''\n\ntype J1 = Join&lt;['a', 'b', 'c'], '.'&gt;  \/\/ \"a.b.c\"\n\n\/\/ CamelCase \u2192 snake_case \u5909\u63db\ntype CamelToSnake&lt;T extends string&gt; =\n  T extends `${infer Head}${infer Tail}`\n    ? Tail extends Uncapitalize&lt;Tail&gt;\n      ? `${Lowercase&lt;Head&gt;}${CamelToSnake&lt;Tail&gt;}`\n      : `${Lowercase&lt;Head&gt;}_${CamelToSnake&lt;Tail&gt;}`\n    : T\n\n\/\/ \u203b\u6ce8\u610f: \u4e0a\u8a18\u306f\u7c21\u6613\u5b9f\u88c5\u3002\u5b9f\u969b\u306f\u5927\u6587\u5b57\u306e\u30d1\u30bf\u30fc\u30f3\u304c\u8907\u96d1\n\n\/\/ Paths\uff08\u30cd\u30b9\u30c8\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5168\u30d1\u30b9\u3092\u62bd\u51fa\uff09\ntype Paths&lt;T, P extends string = ''&gt; =\n  T extends object\n    ? { [K in keyof T &amp; string]:\n        P extends '' ? K | `${K}.${Paths&lt;T[K], K&gt;}`\n                     : `${K}` | `${K}.${Paths&lt;T[K], K&gt;}`\n      }[keyof T &amp; string]\n    : never\n\ntype Config = {\n  user: { name: string; address: { city: string; zip: string } }\n  theme: string\n}\n\ntype ConfigPaths = Paths&lt;Config&gt;\n\/\/ \"user\" | \"user.name\" | \"user.address\" | \"user.address.city\" | \"user.address.zip\" | \"theme\"\n\n\/\/ \u30d5\u30a9\u30fc\u30e0\u3084getter\u306e\u5b9f\u88c5\u306b\u4f7f\u3048\u308b\u30d1\u30bf\u30fc\u30f3\nfunction getConfigValue&lt;T extends Config&gt;(obj: T, path: Paths&lt;T&gt;): unknown {\n  \/\/ path\u306b\u57fa\u3065\u3044\u3066\u30cd\u30b9\u30c8\u3057\u305f\u5024\u3092\u53d6\u5f97\n  return path.split('.').reduce((acc, key) =&gt; (acc as any)?.[key], obj)\n}<\/code><\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9f\u8df5\u7684\u306a\u30ab\u30b9\u30bf\u30e0\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b<\/h2>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-typescript\" data-lang=\"TypeScript\"><code>&gt;\/\/ ===== API\u30ec\u30b9\u30dd\u30f3\u30b9\u7528\u306e\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b =====\n\n\/\/ API\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u6210\u529f\/\u5931\u6557\u578b\u304b\u3089\u5b9f\u969b\u306e\u30c7\u30fc\u30bf\u578b\u3092\u53d6\u308a\u51fa\u3059\ntype ApiResponse&lt;T&gt; =\n  | { status: 'success'; data: T }\n  | { status: 'error'; code: string; message: string }\n\ntype ExtractData&lt;R&gt; = R extends { status: 'success'; data: infer D } ? D : never\ntype ExtractError&lt;R&gt; = R extends { status: 'error' } ? R : never\n\ntype UserResponse = ApiResponse&lt;{ id: number; name: string }&gt;\ntype UserData = ExtractData&lt;UserResponse&gt;\n\/\/ \u2192 { id: number; name: string }\n\n\/\/ \u30ea\u30af\u30a8\u30b9\u30c8\/\u30ec\u30b9\u30dd\u30f3\u30b9\u306e\u578b\u3092\u5b89\u5168\u306b\u6271\u3046\ntype ApiResult&lt;T&gt; =\n  | { ok: true; data: T }\n  | { ok: false; error: Error }\n\nfunction isOk&lt;T&gt;(result: ApiResult&lt;T&gt;): result is { ok: true; data: T } {\n  return result.ok === true\n}\n\n\/\/ ===== \u30d5\u30a9\u30fc\u30e0\u7528\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b =====\n\n\/\/ \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5168\u30ad\u30fc\u3092\u6587\u5b57\u5217\u3067\u30d1\u30b9\u5316\ntype FieldPath&lt;T&gt; = {\n  [K in keyof T]: K extends string\n    ? T[K] extends Record&lt;string, any&gt;\n      ? K | `${K}.${FieldPath&lt;T[K]&gt;}`\n      : K\n    : never\n}[keyof T]\n\ntype FormValues = {\n  user: { name: string; email: string }\n  age: number\n  address: { city: string; zip: string }\n}\ntype FormPaths = FieldPath&lt;FormValues&gt;\n\/\/ \"user\" | \"user.name\" | \"user.email\" | \"age\" | \"address\" | \"address.city\" | \"address.zip\"\n\n\/\/ ===== \u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u8a2d\u8a08\u7528\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b =====\n\n\/\/ PropsWithChildren \u306e\u6c4e\u7528\u7248\ntype WithChildren&lt;T = {}&gt; = T &amp; { children?: React.ReactNode }\n\n\/\/ className \u3092 optional \u306b\u8ffd\u52a0\ntype WithClassName&lt;T = {}&gt; = T &amp; { className?: string }\n\n\/\/ \u7279\u5b9a\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u30aa\u30fc\u30d0\u30fc\u30e9\u30a4\u30c9\u53ef\u80fd\u306b\u3059\u308b\ntype Override&lt;T, U&gt; = Omit&lt;T, keyof U&gt; &amp; U\n\n\/\/ a\u30bf\u30b0\u304bbutton\u30bf\u30b0\u304b\u3092\u578b\u3067\u5207\u308a\u66ff\u3048\u308b\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30c3\u30af\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\ntype PolymorphicRef&lt;T extends React.ElementType&gt; =\n  React.ComponentPropsWithRef&lt;T&gt;['ref']\n\ntype PolymorphicProps&lt;T extends React.ElementType, Props = {}&gt; = {\n  as?: T\n  ref?: PolymorphicRef&lt;T&gt;\n} &amp; Props &amp; Omit&lt;React.ComponentPropsWithoutRef&lt;T&gt;, keyof Props | 'as'&gt;\n\n\/\/ ===== \u72b6\u614b\u7ba1\u7406\u7528\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b =====\n\n\/\/ \u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u30fc\u578b\u3092\u81ea\u52d5\u751f\u6210\ntype EventHandlers&lt;T&gt; = {\n  [K in keyof T as K extends string ? `on${Capitalize&lt;K&gt;}` : never]?: (value: T[K]) =&gt; void\n}\n\ntype State = { count: number; name: string; active: boolean }\ntype Handlers = EventHandlers&lt;State&gt;\n\/\/ \u2192 { onCount?: (value: number) =&gt; void; onName?: (value: string) =&gt; void; onActive?: (value: boolean) =&gt; void }<\/code><\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u3088\u304f\u3042\u308b\u843d\u3068\u3057\u7a74\u3068\u89e3\u6c7a\u7b56<\/h2>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-typescript\" data-lang=\"TypeScript\"><code>&gt;\/\/ ===== \u3088\u304f\u3042\u308b\u843d\u3068\u3057\u7a74 =====\n\n\/\/ \u843d\u3068\u3057\u7a741: never \u3068 Union Distribution\ntype IsNeverWrong&lt;T&gt; = T extends never ? true : false\ntype WrongResult = IsNeverWrong&lt;never&gt;  \/\/ never\uff01\uff08true\u306b\u306a\u3089\u306a\u3044\uff09\n\n\/\/ \u7406\u7531: never \u304cUnion Distribution\u306b\u6e21\u3055\u308c\u308b\u3068\u4f55\u3082\u5206\u914d\u3055\u308c\u305anever\u304c\u8fd4\u308b\n\/\/ \u89e3\u6c7a: [] \u3067\u30e9\u30c3\u30d7\u3057\u3066\u5206\u914d\u3092\u6291\u5236\u3059\u308b\ntype IsNeverCorrect&lt;T&gt; = [T] extends [never] ? true : false\ntype CorrectResult = IsNeverCorrect&lt;never&gt;  \/\/ true \u2705\n\n\/\/ \u843d\u3068\u3057\u7a742: any \u306f\u5168\u3066\u306e extends \u3092 true \u306b\u3059\u308b\ntype IsString&lt;T&gt; = T extends string ? true : false\ntype AnyResult = IsString&lt;any&gt;  \/\/ boolean\uff08true | false\uff09\n\n\/\/ any \u3092\u6e21\u3059\u3068\u6761\u4ef6\u304c\u4e0d\u5b9a\u306b\u306a\u308aboolean\u578b\u306b\u306a\u308b\n\/\/ \u89e3\u6c7a: any\u3092\u7279\u5225\u6271\u3044\u3059\u308b\ntype IsStringStrict&lt;T&gt; = [T] extends [string] ? true : false\n\/\/ \u3053\u308c\u3067\u3082any\u306ftrue\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u5834\u5408\u304c\u3042\u308b\u305f\u3081\u3001any\u30c1\u30a7\u30c3\u30af\u3092\u52a0\u3048\u308b\n\n\/\/ \u843d\u3068\u3057\u7a743: Union Distribution\u304c\u610f\u56f3\u3057\u306a\u3044\u5206\u914d\u3092\u8d77\u3053\u3059\u5834\u5408\ntype WrapInArray&lt;T&gt; = T extends any ? [T] : never\ntype WrappedUnion = WrapInArray&lt;string | number&gt;\n\/\/ \u2192 [string] | [number]\uff08\u5206\u914d\u3067\u5225\u3005\u306e\u30bf\u30d7\u30eb\u306b\u306a\u308b\uff09\n\n\/\/ \u5206\u914d\u3092\u6291\u5236\u3057\u305f\u3044\u5834\u5408\ntype WrapInArrayNoDistribute&lt;T&gt; = [T] extends [any] ? [T] : never\ntype Wrapped = WrapInArrayNoDistribute&lt;string | number&gt;\n\/\/ \u2192 [string | number]\uff08Union\u5168\u4f53\u3092\u3072\u3068\u3064\u306e\u30bf\u30d7\u30eb\u306b\uff09\n\n\/\/ \u843d\u3068\u3057\u7a744: infer\u306e\u5171\u5909\u30fb\u53cd\u5909\n\/\/ \u95a2\u6570\u306e\u5f15\u6570\u306finfer\u3067\u53d6\u308a\u51fa\u3059\u3068Union\u3067\u306f\u306a\u304fIntersection\u306b\u306a\u308b\ntype FnUnion = ((x: string) =&gt; void) | ((x: number) =&gt; void)\ntype ParamsUnion = FnUnion extends (...args: infer P) =&gt; void ? P : never\n\/\/ \u2192 [x: string &amp; number]\uff08Intersection\u306b\u306a\u308b\uff01\uff09\n\n\/\/ \u89e3\u6c7a: Union\u578b\u306e\u5f15\u6570\u3092\u5225\u3005\u306b\u6271\u3046\u5834\u5408\u306f\u500b\u5225\u306b\u51e6\u7406\u3059\u308b<\/code><\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u578b\u30c6\u30b9\u30c8\u306e\u66f8\u304d\u65b9<\/h2>\n\n\n  <div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-markup\" data-lang=\"HTML\"><code>&gt;\/\/ ===== \u578b\u30c6\u30b9\u30c8\u306e\u65b9\u6cd5 =====\n\n\/\/ \u65b9\u6cd51: @ts-expect-error \u3092\u4f7f\u3063\u305f\u30c6\u30b9\u30c8\nconst test: string = '' as unknown as string\n\/\/ @ts-expect-error: string \u306f number \u306b\u4ee3\u5165\u4e0d\u53ef\nconst shouldFail: number = test  \/\/ \u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3053\u3068\u3092\u78ba\u8a8d\n\n\/\/ \u65b9\u6cd52: Expect + Equal \u578b\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\uff08type-fest\u30e9\u30a4\u30d6\u30e9\u30ea\uff09\ntype Expect&lt;T extends true&gt; = T\ntype Equal&lt;X, Y&gt; = (&lt;T&gt;() =&gt; T extends X ? 1 : 2) extends (&lt;T&gt;() =&gt; T extends Y ? 1 : 2) ? true : false\n\ntype TestSuite = [\n  Expect&lt;Equal&lt;MyReturnType&lt;() =&gt; string&gt;, string&gt;&gt;,\n  Expect&lt;Equal&lt;MyExtract&lt;'a' | 'b' | 'c', 'a'&gt;, 'a'&gt;&gt;,\n  Expect&lt;Equal&lt;UnwrapPromise&lt;Promise&lt;number&gt;&gt;, number&gt;&gt;,\n  Expect&lt;Equal&lt;Head&lt;[1, 2, 3]&gt;, 1&gt;&gt;,\n]\n\/\/ \u2191 \u5168\u3066 true \u306b\u306a\u308c\u3070\u578b\u30c6\u30b9\u30c8\u901a\u904e\n\n\/\/ \u65b9\u6cd53: tsd \u30e9\u30a4\u30d6\u30e9\u30ea\uff08\u578b\u30c6\u30b9\u30c8\u5c02\u7528\u30c4\u30fc\u30eb\uff09\n\/\/ npm install --save-dev tsd\nimport { expectType, expectError } from 'tsd'\n\nexpectType&lt;string&gt;('' as MyReturnType&lt;() =&gt; string&gt;)\nexpectType&lt;'a' | 'b'&gt;('' as MyExtract&lt;'a' | 'b' | 'c', 'a' | 'b'&gt;)\n\n\/\/ \u578b\u30c6\u30b9\u30c8\u3092 CI\/CD \u306b\u7d44\u307f\u8fbc\u3093\u3067\u578b\u306e\u6b63\u78ba\u6027\u3092\u4fdd\u8a3c<\/code><\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u3088\u304f\u3042\u308b\u8cea\u554f\uff08FAQ\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Q1. Conditional Type\u3068\u578b\u30ac\u30fc\u30c9\u306f\u3069\u3046\u4f7f\u3044\u5206\u3051\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> Conditional Type \u306f<strong>\u578b\u5b9a\u7fa9\u306e\u6642\u70b9\u3067\uff08\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\uff09<\/strong>\u578b\u3092\u6761\u4ef6\u5206\u5c90\u3055\u305b\u308b\u3082\u306e\u3067\u3059\u3002\u578b\u30ac\u30fc\u30c9\u306f<strong>\u30e9\u30f3\u30bf\u30a4\u30e0\u3067<\/strong>\u6761\u4ef6\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066TypeScript\u306b\u300c\u3053\u306e\u5206\u5c90\u306e\u4e2d\u3067\u306f\u3053\u306e\u578b\u3060\u300d\u3068\u6559\u3048\u308b\u3082\u306e\u3067\u3059\u3002<code>function isString(x: unknown): x is string { return typeof x === 'string' }<\/code> \u306e\u3088\u3046\u306a\u578b\u30ac\u30fc\u30c9\u306f\u5b9f\u884c\u6642\u306b\u52d5\u4f5c\u3057\u3001Conditional Type\u306f\u578b\u8a08\u7b97\u306e\u969b\u306b\u306e\u307f\u8a55\u4fa1\u3055\u308c\u307e\u3059\u3002\u4e21\u8005\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3046\u3053\u3068\u304c\u591a\u304f\u3001Conditional Type\u3067\u300c\u3042\u308b\u95a2\u6570\u304c\u8fd4\u3059\u578b\u3092\u8a08\u7b97\u300d\u3057\u3001\u578b\u30ac\u30fc\u30c9\u3067\u300c\u5b9f\u884c\u6642\u306b\u305d\u306e\u578b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u300d\u3059\u308b\u30d1\u30bf\u30fc\u30f3\u304c\u5b9f\u8df5\u7684\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q2. \u518d\u5e30\u7684\u306a\u6761\u4ef6\u578b\u3067TypeScript\u304c\u9045\u304f\u306a\u308b\u5834\u5408\u306f\u3069\u3046\u3059\u308c\u3070\u3044\u3044\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> \u518d\u5e30\u7684\u306a\u578b\u306f\u6df1\u3059\u304e\u308b\u3068 <strong>\u300cType instantiation is excessively deep\u300d<\/strong> \u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3059\u3002\u89e3\u6c7a\u7b56\u306f\u2460\u518d\u5e30\u306e\u6df1\u3055\u3092\u5236\u9650\u3059\u308b\u30ab\u30a6\u30f3\u30bf\u30fc\u3092\u578b\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3067\u6301\u3064\u2461<code>interface<\/code>\u3092\u4f7f\u3063\u305f\u9045\u5ef6\u8a55\u4fa1\u2462\u305d\u3082\u305d\u3082\u6df1\u3044\u518d\u5e30\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u5b9f\u884c\u6642\u51e6\u7406\u306b\u5207\u308a\u66ff\u3048\u308b\u306e3\u3064\u3067\u3059\u3002TypeScript\u306e\u30b3\u30f3\u30d1\u30a4\u30e9\u30fc\u306f\u578b\u306e\u518d\u5e30\u6df1\u3055\u306b\u4e0a\u9650\uff08\u30c7\u30d5\u30a9\u30eb\u30c81000\uff09\u304c\u3042\u308b\u305f\u3081\u3001\u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30fc\u30bf\u306e\u6df1\u3055\u306b\u5408\u308f\u305b\u305f\u8a2d\u8a08\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q3. infer\u3067\u63a8\u8ad6\u3055\u308c\u305f\u578b\u306e\u7bc4\u56f2\u306f\u3069\u3046\u5236\u9650\u3057\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> TypeScript 4.7\u4ee5\u964d\u3001<code>infer R extends string<\/code> \u306e\u3088\u3046\u306b<strong>infer\u306b extends\u5236\u7d04\u3092\u4ed8\u3051\u308b<\/strong>\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<code>type FirstString&lt;T&gt; = T extends [infer F extends string, ...any[]] ? F : never<\/code> \u306e\u3088\u3046\u306b\u66f8\u304f\u3068\u3001F\u306fstring\u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3068\u3057\u3066\u30ad\u30e3\u30d7\u30c1\u30e3\u3055\u308c\u307e\u3059\u30024.7\u4ee5\u524d\u306f\u63a8\u8ad6\u5f8c\u306b\u5225\u306eConditional Type\u3067\u5236\u7d04\u3092\u304b\u3051\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q4. Conditional Type\u3068Mapped Type\u306f\u3069\u3046\u4f7f\u3044\u5206\u3051\u307e\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> <strong>Mapped Type\uff08<code>{ [K in keyof T]: ... }<\/code>\uff09<\/strong>\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5404\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u5909\u63db\u3059\u308b\u306e\u306b\u4f7f\u3044\u307e\u3059\u3002<strong>Conditional Type<\/strong>\u306f\u578b\u305d\u306e\u3082\u306e\u3092\u6761\u4ef6\u3067\u5207\u308a\u66ff\u3048\u308b\u306e\u306b\u4f7f\u3044\u307e\u3059\u3002\u5b9f\u969b\u306b\u306f\u4e21\u8005\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u591a\u304f\u3001Mapped Type\u306eKey Remapping\uff08<code>as<\/code>\u7bc0\uff09\u3067Conditional Type\u3092\u4f7f\u3063\u3066\u7279\u5b9a\u30ad\u30fc\u3092\u9664\u5916\u30fb\u30ea\u30cd\u30fc\u30e0\u3059\u308b\u30d1\u30bf\u30fc\u30f3\u304c\u5f37\u529b\u3067\u3059\u3002\u4f8b\u3048\u3070 <code>[K in keyof T as T[K] extends string ? K : never]<\/code> \u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u6587\u5b57\u5217\u578b\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3060\u3051\u3092\u62bd\u51fa\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Q5. never\u578b\u304c\u6761\u4ef6\u578b\u306e\u4e2d\u3067\u300c\u6d88\u3048\u308b\u300d\u306e\u306f\u306a\u305c\u3067\u3059\u304b\uff1f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>A.<\/strong> TypeScript\u3067\u306f <code>A | never<\/code> \u306f <code>A<\/code> \u3068\u540c\u7b49\u3067\u3059\u3002Union\u578b\u306bnever\u304c\u542b\u307e\u308c\u308b\u3068\u81ea\u52d5\u7684\u306b\u53d6\u308a\u9664\u304b\u308c\u307e\u3059\u3002\u307e\u305f\u5206\u914d\u7684\u6761\u4ef6\u578b\u3067\u306f\u3001never\u3092\u578b\u5909\u6570\u306b\u6e21\u3059\u3068\u300c\u5206\u914d\u3059\u308b\u30e1\u30f3\u30d0\u30fc\u304c0\u500b\u300d\u3068\u3044\u3046\u72b6\u614b\u306b\u306a\u308b\u305f\u3081\u3001\u7d50\u679c\u3082never\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u306fExclude\u306a\u3069\u306e\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b\u3067\u610f\u56f3\u7684\u306b\u5229\u7528\u3055\u308c\u3066\u3044\u307e\u3059\uff08\u9664\u5916\u3057\u305f\u3044\u578b\u3092never\u306b\u3059\u308b\u3053\u3068\u3067Union\u304b\u3089\u53d6\u308a\u9664\u304f\uff09\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n  <ul class=\"wp-block-list\">\n    <li><strong>\u57fa\u672c\u69cb\u6587<\/strong>\uff1a<code>T extends U ? X : Y<\/code> \u3067T\u304cU\u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u304b\u3092\u5224\u5b9a\u3057\u3066\u578b\u3092\u5206\u5c90\u3055\u305b\u308b\u3002<\/li>\n    <li><strong>Union Distribution\uff08\u5206\u914d\uff09<\/strong>\uff1aT\u304c\u578b\u5909\u6570\u3067Union\u578b\u306e\u5834\u5408\u3001\u5404\u30e1\u30f3\u30d0\u30fc\u306b\u500b\u5225\u306b\u6761\u4ef6\u578b\u304c\u9069\u7528\u3055\u308c\u308b\u3002Extract\u3084Exclude\u306f\u3053\u308c\u3092\u5229\u7528\u3002<\/li>\n    <li><strong>\u5206\u914d\u306e\u6291\u5236<\/strong>\uff1a<code>[T] extends [U]<\/code> \u306e\u3088\u3046\u306b\u30bf\u30d7\u30eb\u3067\u30e9\u30c3\u30d7\u3059\u308b\u3068\u5206\u914d\u3092\u6291\u5236\u3002never\u306e\u30c1\u30a7\u30c3\u30af\u306b\u91cd\u8981\u3002<\/li>\n    <li><strong>infer<\/strong>\uff1a\u6761\u4ef6\u90e8\u3067\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u3057\u305f\u578b\u3092\u5909\u6570\u3068\u3057\u3066\u6355\u6349\u3002ReturnType\u30fbParameters\u30fbUnwrapPromise\u7b49\u306e\u5b9f\u88c5\u306b\u6d3b\u7528\u3002<\/li>\n    <li><strong>\u7d44\u307f\u8fbc\u307f\u578b\u306e\u81ea\u4f5c<\/strong>\uff1aExclude\u30fbExtract\u30fbNonNullable\u30fbParameters\u30fbConstructorParameters\u30fbInstanceType\u5168\u3066Conditional Type\u3067\u5b9f\u88c5\u3055\u308c\u3066\u3044\u308b\u3002<\/li>\n    <li><strong>\u518d\u5e30\u7684\u6761\u4ef6\u578b<\/strong>\uff1aTypeScript 4.1\u4ee5\u964d\u3067\u5bfe\u5fdc\u3002DeepPartial\u30fbDeepReadonly\u30fbFlatten\u306a\u3069\u306e\u6df1\u3044\u5909\u63db\u578b\u304c\u5b9f\u88c5\u53ef\u80fd\u3002<\/li>\n    <li><strong>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30ea\u30c6\u30e9\u30eb\u578b\u3068\u306e\u7d44\u307f\u5408\u308f\u305b<\/strong>\uff1aSplit\u30fbJoin\u30fbCamelToSnake\u30fbPaths\u306a\u3069\u5f37\u529b\u306a\u6587\u5b57\u5217\u578b\u64cd\u4f5c\u304c\u53ef\u80fd\u3002<\/li>\n    <li><strong>\u3088\u304f\u3042\u308b\u843d\u3068\u3057\u7a74<\/strong>\uff1anever\u306eDistribution\u30fbany\u306e\u6319\u52d5\u30fb\u95a2\u6570\u306e\u5f15\u6570\u306eIntersection\u5316\u306b\u6ce8\u610f\u3002<\/li>\n  <\/ul>\n\n\n\n  <p class=\"wp-block-paragraph\"><strong><span class=\"swl-marker mark_yellow\">Conditional Type\u306fTypeScript\u306e\u300c\u578b\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u3059\u308b\u300d\u6a5f\u80fd\u306e\u4e2d\u6838\u3067\u3059\u3002\u307e\u305a\u306fReturnType\u30fbExtract\u30fbExclude\u3092\u81ea\u4f5c\u3057\u3066\u52d5\u4f5c\u3092\u4f53\u611f\u3057\u3066\u304b\u3089\u3001infer\u3092\u4f7f\u3063\u305fUnwrapPromise\u3084DeepPartial\u306e\u5b9f\u88c5\u306b\u6311\u6226\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u578b\u30d1\u30ba\u30eb\u3092\u697d\u3057\u307f\u306a\u304c\u3089\u5b66\u3076\u3068\u7406\u89e3\u304c\u6df1\u307e\u308a\u307e\u3059\u3002<\/span><\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<!-- withmedia-related -->\n<h2 class=\"wp-block-heading\">\u95a2\u9023\u8a18\u4e8b<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/withcode.tech\/media\/wcstack-state-reactive-dom\/\">@wcstack\/state\u3067HTML\u306b\u30ea\u30a2\u30af\u30c6\u30a3\u30d6\u306a\u72b6\u614b\u7ba1\u7406\u3092\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u30d3\u30eb\u30c9\u30ec\u30b9\u30fb\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306a\u3057\u3067DOM\u3092\u81ea\u52d5\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\u3092\u5fb9\u5e95\u89e3\u8aac<\/a><\/li>\n<li><a href=\"https:\/\/withcode.tech\/media\/webassembly-javascript-data-exchange\/\">WebAssembly\u3068JavaScript\u9593\u306e\u30c7\u30fc\u30bf\u3084\u308a\u3068\u308a\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u7dda\u5f62\u30e1\u30e2\u30ea\u30fbArrayBuffer\u30fb\u6587\u5b57\u5217\u30fbserde-wasm-bindgen\u30fbSharedArrayBuffer\u30fb\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u30fb\u30e1\u30e2\u30ea\u7ba1\u7406\u307e\u3067\u5fb9\u5e95\u89e3\u8aac<\/a><\/li>\n<li><a href=\"https:\/\/withcode.tech\/media\/typescript-literal-types-guide\/\">TypeScript\u306e\u30ea\u30c6\u30e9\u30eb\u578b\u5b8c\u5168\u30ac\u30a4\u30c9\uff5c\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30ea\u30c6\u30e9\u30eb\u578b\u30fbconst\u30a2\u30b5\u30fc\u30b7\u30e7\u30f3\u30fb\u578b\u5b89\u5168CSS-in-JS\u30fbTailwind CVA\u30fbvanilla-extract\u30fb\u30c7\u30b6\u30a4\u30f3\u30c8\u30fc\u30af\u30f3\u5b9f\u88c5\u307e\u3067\u5fb9\u5e95\u89e3\u8aac<\/a><\/li>\n<li><a href=\"https:\/\/withcode.tech\/media\/zod-typescript-validation-guide\/\">Zod\u5b8c\u5168\u30ac\u30a4\u30c9\uff5cTypeScript\u306eAPI\u30d0\u30ea\u30c7\u30fc\u30b7\u30e7\u30f3\u30fb\u30b9\u30ad\u30fc\u30de\u5168\u578b\u8a73\u89e3\u30fbrefine\u30fbtransform\u30fb\u74b0\u5883\u5909\u6570\u691c\u8a3c\u30fbtRPC\u9023\u643a\u30fbReact Hook Form\u30fbYup\u6bd4\u8f03\u307e\u3067\u5fb9\u5e95\u89e3\u8aac<\/a><\/li>\n<li><a href=\"https:\/\/withcode.tech\/media\/micro-frontends-guide\/\">\u30de\u30a4\u30af\u30ed\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5b8c\u5168\u30ac\u30a4\u30c9\uff5cModule Federation\u306e\u4ed5\u7d44\u307f\u304b\u3089Vite\u30fbwebpack\u5b9f\u88c5\u30fbMFE\u9593\u901a\u4fe1\u30fbCI\/CD\u30c7\u30d7\u30ed\u30a4\u6226\u7565\u307e\u3067\u5fb9\u5e95\u89e3\u8aac<\/a><\/li>\n<li><a href=\"https:\/\/withcode.tech\/media\/astro-ga4-partytown\/\">Astro\u306bGoogle Analytics 4\u3092Partytown\u3067\u5c0e\u5165\u3059\u308b\u65b9\u6cd5\u3010\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6700\u9069\u5316\u3011<\/a><\/li>\n<li><a href=\"https:\/\/withcode.tech\/media\/typescript-type-safety-benefits\/\">\u3010\u5b8c\u5168\u30ac\u30a4\u30c9\u3011TypeScript\u306e\u578b\u5b89\u5168\u6027\u304cWeb\u5236\u4f5c\u306b\u3082\u305f\u3089\u30595\u3064\u306e\u30e1\u30ea\u30c3\u30c8\uff5c\u5c0e\u5165\u304b\u3089\u5b9f\u8df5\u307e\u3067\u5fb9\u5e95\u89e3\u8aac<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<!-- withmedia-references -->\n<h2 class=\"wp-block-heading\">\u53c2\u8003\u30ea\u30f3\u30af\uff08\u516c\u5f0f\u30fb\u4e00\u6b21\u60c5\u5831\uff09<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/developer.mozilla.org\/ja\/docs\/Web\/JavaScript\" target=\"_blank\" rel=\"noopener noreferrer\">MDN Web Docs \u2014 JavaScript<\/a><\/li>\n<li><a href=\"https:\/\/ja.react.dev\/\" target=\"_blank\" rel=\"noopener noreferrer\">React \u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a><\/li>\n<li><a href=\"https:\/\/www.typescriptlang.org\/docs\/\" target=\"_blank\" rel=\"noopener noreferrer\">TypeScript \u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<h2 class=\"wp-block-heading\">AI\u30b9\u30ad\u30eb\u3067\u3001\u672a\u6765\u306e\u81ea\u5206\u3092\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\uff01<\/h2>\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/s.lmes.jp\/landing-qr\/2010578884-C5To3Fmv?uLand=phzKXf\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" width=\"1254\" height=\"1254\" src=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/07\/withai-cta-banner.jpg\" alt=\"\u4eca\u306a\u3089\u5b8c\u5168\u7121\u6599\u3067AI\u3092\u5b66\u3079\u308b\uff01WithAI\" class=\"wp-image-18841\" style=\"max-width:600px;width:100%;height:auto\" srcset=\"https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/07\/withai-cta-banner.jpg 1254w, https:\/\/withcode.tech\/media\/wp-content\/uploads\/2026\/07\/withai-cta-banner-768x768.jpg 768w\" sizes=\"(max-width: 1254px) 100vw, 1254px\" \/><\/a><\/figure>\n\n<h3 class=\"wp-block-heading\">\u4eca\u306a\u3089\u5b8c\u5168\u7121\u6599\u3067AI\u3092\u5b66\u3079\u308b\uff01<\/h3>\n\n<ul class=\"wp-block-list\">\n<li><strong>\u52d5\u753b\u3084\u5b9f\u8df5\u3067\u697d\u3057\u304f\u5b66\u3079\u308b<\/strong>\uff1a\u521d\u5fc3\u8005\u3067\u3082\u5b89\u5fc3\u306e\u30ab\u30ea\u30ad\u30e5\u30e9\u30e0<\/li>\n<li><strong>\u30b9\u30de\u30db\u30fbPC\u3069\u3061\u3089\u3067\u3082OK<\/strong>\uff1a\u597d\u304d\u306a\u6642\u9593\u306b\u5b66\u7fd2\u3067\u304d\u308b<\/li>\n<li><strong>\u6599\u91d1\u306f\u4e00\u5207\u30ca\u30b7<\/strong>\uff1a<span class=\"swl-marker mark_yellow\">0\u5186\u3067AI\u30b9\u30ad\u30eb\u304c\u8eab\u306b\u3064\u304f<\/span><\/li>\n<\/ul>\n\n<p>\u76ee\u7684\u306b\u5408\u308f\u305b\u3066\u9078\u3079\u308b\u300cAI\u526f\u696d\u300d\u300cAI\u8ee2\u8077\u300d\u300cAI\u6d3b\u7528\u300d\u306e3\u30b3\u30fc\u30b9\u3092\u7528\u610f\u3002\u526f\u53ce\u5165\u30fb\u30ad\u30e3\u30ea\u30a2\u30c1\u30a7\u30f3\u30b8\u30fb\u65e5\u5e38\u306e\u751f\u7523\u6027\u30a2\u30c3\u30d7\u307e\u3067\u3001\u3042\u306a\u305f\u306e\u30b4\u30fc\u30eb\u306b\u5408\u308f\u305b\u3066AI\u3092\u5b66\u3079\u307e\u3059\u3002<\/p>\n\n<p>\u4f1a\u54e1\u767b\u9332\u306f\u30ab\u30f3\u30bf\u30f330\u79d2\u3067\u5b8c\u4e86\u3057\u307e\u3059\u3002\u307e\u305a\u306f\u516c\u5f0fLINE\u304b\u3089\u3001\u7121\u6599\u3067AI\u5b66\u7fd2\u3092\u30b9\u30bf\u30fc\u30c8\u3057\u307e\u3057\u3087\u3046\uff01<\/p>\n\n<div class=\"wp-block-buttons\"><div class=\"wp-block-button\"><a class=\"wp-block-button__link has-white-color has-text-color has-background has-link-color wp-element-button\" href=\"https:\/\/s.lmes.jp\/landing-qr\/2010578884-C5To3Fmv?uLand=phzKXf\" target=\"_blank\" rel=\"noopener noreferrer\" style=\"background-color:#06c755\"><strong>\u516c\u5f0fLINE\u304b\u3089\u5b66\u7fd2\u3092\u30b9\u30bf\u30fc\u30c8<\/strong><\/a><\/div><\/div>\n\n\n<!-- withmedia-faq-schema -->\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Conditional Type\u3068\u578b\u30ac\u30fc\u30c9\u306f\u3069\u3046\u4f7f\u3044\u5206\u3051\u307e\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Conditional Type \u306f\u578b\u5b9a\u7fa9\u306e\u6642\u70b9\u3067\uff08\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\uff09\u578b\u3092\u6761\u4ef6\u5206\u5c90\u3055\u305b\u308b\u3082\u306e\u3067\u3059\u3002\u578b\u30ac\u30fc\u30c9\u306f\u30e9\u30f3\u30bf\u30a4\u30e0\u3067\u6761\u4ef6\u3092\u30c1\u30a7\u30c3\u30af\u3057\u3066TypeScript\u306b\u300c\u3053\u306e\u5206\u5c90\u306e\u4e2d\u3067\u306f\u3053\u306e\u578b\u3060\u300d\u3068\u6559\u3048\u308b\u3082\u306e\u3067\u3059\u3002function isString(x: unknown): x is string { return typeof x === 'string' } \u306e\u3088\u3046\u306a\u578b\u30ac\u30fc\u30c9\u306f\u5b9f\u884c\u6642\u306b\u52d5\u4f5c\u3057\u3001Conditional Type\u306f\u578b\u8a08\u7b97\u306e\u969b\u306b\u306e\u307f\u8a55\u4fa1\u3055\u308c\u307e\u3059\u3002\u4e21\u8005\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3046\u3053\u3068\u304c\u591a\u304f\u3001Conditional Type\u3067\u300c\u3042\u308b\u95a2\u6570\u304c\u8fd4\u3059\u578b\u3092\u8a08\u7b97\u300d\u3057\u3001\u578b\u30ac\u30fc\u30c9\u3067\u300c\u5b9f\u884c\u6642\u306b\u305d\u306e\u578b\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u300d\u3059\u308b\u30d1\u30bf\u30fc\u30f3\u304c\u5b9f\u8df5\u7684\u3067\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"\u518d\u5e30\u7684\u306a\u6761\u4ef6\u578b\u3067TypeScript\u304c\u9045\u304f\u306a\u308b\u5834\u5408\u306f\u3069\u3046\u3059\u308c\u3070\u3044\u3044\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"\u518d\u5e30\u7684\u306a\u578b\u306f\u6df1\u3059\u304e\u308b\u3068 \u300cType instantiation is excessively deep\u300d \u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3059\u3002\u89e3\u6c7a\u7b56\u306f\u2460\u518d\u5e30\u306e\u6df1\u3055\u3092\u5236\u9650\u3059\u308b\u30ab\u30a6\u30f3\u30bf\u30fc\u3092\u578b\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3067\u6301\u3064\u2461interface\u3092\u4f7f\u3063\u305f\u9045\u5ef6\u8a55\u4fa1\u2462\u305d\u3082\u305d\u3082\u6df1\u3044\u518d\u5e30\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u5b9f\u884c\u6642\u51e6\u7406\u306b\u5207\u308a\u66ff\u3048\u308b\u306e3\u3064\u3067\u3059\u3002TypeScript\u306e\u30b3\u30f3\u30d1\u30a4\u30e9\u30fc\u306f\u578b\u306e\u518d\u5e30\u6df1\u3055\u306b\u4e0a\u9650\uff08\u30c7\u30d5\u30a9\u30eb\u30c81000\uff09\u304c\u3042\u308b\u305f\u3081\u3001\u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30c7\u30fc\u30bf\u306e\u6df1\u3055\u306b\u5408\u308f\u305b\u305f\u8a2d\u8a08\u304c\u91cd\u8981\u3067\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"infer\u3067\u63a8\u8ad6\u3055\u308c\u305f\u578b\u306e\u7bc4\u56f2\u306f\u3069\u3046\u5236\u9650\u3057\u307e\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"TypeScript 4.7\u4ee5\u964d\u3001infer R extends string \u306e\u3088\u3046\u306binfer\u306b extends\u5236\u7d04\u3092\u4ed8\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002type FirstString<T> = T extends [infer F extends string, ...any[]] ? F : never \u306e\u3088\u3046\u306b\u66f8\u304f\u3068\u3001F\u306fstring\u306e\u30b5\u30d6\u30bf\u30a4\u30d7\u3068\u3057\u3066\u30ad\u30e3\u30d7\u30c1\u30e3\u3055\u308c\u307e\u3059\u30024.7\u4ee5\u524d\u306f\u63a8\u8ad6\u5f8c\u306b\u5225\u306eConditional Type\u3067\u5236\u7d04\u3092\u304b\u3051\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3057\u305f\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"Conditional Type\u3068Mapped Type\u306f\u3069\u3046\u4f7f\u3044\u5206\u3051\u307e\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Mapped Type\uff08{ [K in keyof T]: ... }\uff09\u306f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5404\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u5909\u63db\u3059\u308b\u306e\u306b\u4f7f\u3044\u307e\u3059\u3002Conditional Type\u306f\u578b\u305d\u306e\u3082\u306e\u3092\u6761\u4ef6\u3067\u5207\u308a\u66ff\u3048\u308b\u306e\u306b\u4f7f\u3044\u307e\u3059\u3002\u5b9f\u969b\u306b\u306f\u4e21\u8005\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u304c\u591a\u304f\u3001Mapped Type\u306eKey Remapping\uff08as\u7bc0\uff09\u3067Conditional Type\u3092\u4f7f\u3063\u3066\u7279\u5b9a\u30ad\u30fc\u3092\u9664\u5916\u30fb\u30ea\u30cd\u30fc\u30e0\u3059\u308b\u30d1\u30bf\u30fc\u30f3\u304c\u5f37\u529b\u3067\u3059\u3002\u4f8b\u3048\u3070 [K in keyof T as T[K] extends string ? K : never] \u306e\u3088\u3046\u306b\u66f8\u3044\u3066\u6587\u5b57\u5217\u578b\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u3060\u3051\u3092\u62bd\u51fa\u3067\u304d\u307e\u3059\u3002\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"never\u578b\u304c\u6761\u4ef6\u578b\u306e\u4e2d\u3067\u300c\u6d88\u3048\u308b\u300d\u306e\u306f\u306a\u305c\u3067\u3059\u304b\uff1f\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"TypeScript\u3067\u306f A | never \u306f A \u3068\u540c\u7b49\u3067\u3059\u3002Union\u578b\u306bnever\u304c\u542b\u307e\u308c\u308b\u3068\u81ea\u52d5\u7684\u306b\u53d6\u308a\u9664\u304b\u308c\u307e\u3059\u3002\u307e\u305f\u5206\u914d\u7684\u6761\u4ef6\u578b\u3067\u306f\u3001never\u3092\u578b\u5909\u6570\u306b\u6e21\u3059\u3068\u300c\u5206\u914d\u3059\u308b\u30e1\u30f3\u30d0\u30fc\u304c0\u500b\u300d\u3068\u3044\u3046\u72b6\u614b\u306b\u306a\u308b\u305f\u3081\u3001\u7d50\u679c\u3082never\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u308c\u306fExclude\u306a\u3069\u306e\u30e6\u30fc\u30c6\u30a3\u30ea\u30c6\u30a3\u578b\u3067\u610f\u56f3\u7684\u306b\u5229\u7528\u3055\u308c\u3066\u3044\u307e\u3059\uff08\u9664\u5916\u3057\u305f\u3044\u578b\u3092never\u306b\u3059\u308b\u3053\u3068\u3067Union\u304b\u3089\u53d6\u308a\u9664\u304f\uff09\u3002\"\n      }\n    }\n  ]\n}\n<\/script>\n\n","protected":false},"excerpt":{"rendered":"<p>TypeScript Conditional Type\uff08T extends U ? X : Y\uff09\u3092\u57fa\u672c\u304b\u3089\u5fdc\u7528\u307e\u3067\u89e3\u8aac\u3002Union\u5206\u914d\u30fbinfer\u3067\u306e\u578b\u62bd\u51fa\u30fb\u518d\u5e30\u7684\u6761\u4ef6\u578b\u30fb\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u30ea\u30c6\u30e9\u30eb\u578b\u3068\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u5b9f\u8df5\u30b3\u30fc\u30c9\u4ed8\u304d\u3067\u7d39\u4ecb\u3002<\/p>\n","protected":false},"author":2,"featured_media":14325,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"swell_btn_cv_data":"","footnotes":"","vk-ltc-link":"","vk-ltc-target":"0"},"categories":[34,359],"tags":[],"class_list":["post-13201","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","category-javascript-programming"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts\/13201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/comments?post=13201"}],"version-history":[{"count":17,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts\/13201\/revisions"}],"predecessor-version":[{"id":19773,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/posts\/13201\/revisions\/19773"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/media\/14325"}],"wp:attachment":[{"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/media?parent=13201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/categories?post=13201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/withcode.tech\/media\/wp-json\/wp\/v2\/tags?post=13201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}