{"id":14606,"date":"2024-03-25T16:48:48","date_gmt":"2024-03-25T07:48:48","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=14606"},"modified":"2024-03-25T17:07:29","modified_gmt":"2024-03-25T08:07:29","slug":"typescript%ec%9d%98-%eb%b0%b0%ec%97%b4%eb%a1%9c-union-type-%ec%a0%95%ec%9d%98%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=14606","title":{"rendered":"TypeScript\uc758 \ubc30\uc5f4\ub85c Union Type \uc815\uc758\ud558\uae30"},"content":{"rendered":"<p>\ub2e4\uc74c\uacfc \uac19\uc740 \ubc30\uc5f4\uc774 \uc788\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"typescript\">\r\nconst SideTypes = [ \"FRONT\", \"BACK\", \"DOUBLE\" ] as const;\r\n<\/pre>\n<p>\uc704\uc758 \ubc30\uc5f4 \uac1d\uccb4\ub97c \uac00\uc9c0\uace0 FRONT\uc640 BACK \ub610\ub294 DOUBLE \ubb38\uc790\uc5f4\uc744 \uac16\ub294 Union Type\uc744 \uc815\uc758\ud558\ub294 \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4. (as const\ub97c \ubc18\ub4dc\uc2dc \ubd99\uc5ec\uc57c \ud55c\ub2e4.)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"typescript\">\r\ntype OptionType = {\r\n  side: typeof SideTypes[number];\r\n};\r\n<\/pre>\n<p>\uc989, \uc704\uc758 \ucf54\ub4dc\ub294 \uc544\ub798\uc640 \ucf54\ub4dc\uc640 \ub3d9\uc77c\ud558\ub2e4. \ud558\uc9c0\ub9cc \uc544\ub798\ucc98\ub7fc\ud558\uba74 \ubc30\uc5f4 \uac1d\uccb4\uc758 \uac12\uacfc \uc720\ub2c8\uc628 \ud0c0\uc785\uc744 \uc815\uc758\ud558\uae30 \uc704\ud55c \uac12\uc5d0 \ub300\ud55c \ucf54\ub4dc\uac00 \uc911\ubcf5\ub418\ub294 \ubb38\uc81c\uac00 \uc788\ub2e4. \uc774\ub294 \ubc18\ub4dc\uc2dc \uace0\uccd0\uc57c \ud558\ub294 \uc544\uc8fc \ub098\uc05c \ub9ac\ud399\ud1a0\ub9c1 \ub300\uc0c1\uc774\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"typescript\">\r\ntype OptionType = {\r\n  side: \"FRONT\" | \"BACK\" | \"DOUBLE\";\r\n};\r\n<\/pre>\n<p>\uc774\uc81c OptionType\uc740 \ub2e4\uc74c\ucc98\ub7fc \uc0ac\uc6a9\ub420 \uc218 \uc788\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"typescript\">\r\nconst options: OptionType = {\r\n  side: \"FRONT\"\r\n};\r\n<\/pre>\n<p>\uc774\uc81c lil-gui \ub77c\uc774\ube0c\ub7ec\ub9ac\uc5d0\uc11c \ub2e4\uc74c\ucc98\ub7fc \ud6a8\uacfc\uc801\uc778 \ucf54\ub4dc\ub85c \uc791\uc131\ub420 \uc218 \uc788\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"typescript\">\r\nconst gui = new GUI();\r\ngui.add(options, \"side\", SideTypes).onChange(v => {\r\n  if(v === \"FRONT\") {\r\n    material.side = THREE.FrontSide;\r\n  } else if(v === \"BACK\") {\r\n    material.side = THREE.BackSide;\r\n  } else if(v === \"DOUBLE\") {\r\n    material.side = THREE.DoubleSide;\r\n  }\r\n});\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\uac00 \uc801\uc6a9\ub41c \uc2e4\ud589 \ud654\uba74\uc778\ub370, \ud654\uba74\uc758 \uc6b0\uce21 \uc0c1\ub2e8\uc758 GUI\ub97c \uc704\ud574 \uc801\uc6a9\ub41c \ucf54\ub4dc\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2024\/03\/typescript_uniontype_array.jpg\" alt=\"\" width=\"1201\" height=\"740\" class=\"aligncenter size-full wp-image-14616\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ub2e4\uc74c\uacfc \uac19\uc740 \ubc30\uc5f4\uc774 \uc788\ub2e4. const SideTypes = [ &#8220;FRONT&#8221;, &#8220;BACK&#8221;, &#8220;DOUBLE&#8221; ] as const; \uc704\uc758 \ubc30\uc5f4 \uac1d\uccb4\ub97c \uac00\uc9c0\uace0 FRONT\uc640 BACK \ub610\ub294 DOUBLE \ubb38\uc790\uc5f4\uc744 \uac16\ub294 Union Type\uc744 \uc815\uc758\ud558\ub294 \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4. (as const\ub97c \ubc18\ub4dc\uc2dc \ubd99\uc5ec\uc57c \ud55c\ub2e4.) type OptionType = { side: typeof SideTypes[number]; }; \uc989, \uc704\uc758 \ucf54\ub4dc\ub294 \uc544\ub798\uc640 \ucf54\ub4dc\uc640 \ub3d9\uc77c\ud558\ub2e4. \ud558\uc9c0\ub9cc \uc544\ub798\ucc98\ub7fc\ud558\uba74 \ubc30\uc5f4 \uac1d\uccb4\uc758 \uac12\uacfc \uc720\ub2c8\uc628 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=14606\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;TypeScript\uc758 \ubc30\uc5f4\ub85c Union Type \uc815\uc758\ud558\uae30&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88,1],"tags":[],"class_list":["post-14606","post","type-post","status-publish","format-standard","hentry","category-javascript","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/14606","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14606"}],"version-history":[{"count":11,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/14606\/revisions"}],"predecessor-version":[{"id":14608,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/14606\/revisions\/14608"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14606"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14606"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14606"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}