{"id":10064,"date":"2020-04-13T08:32:33","date_gmt":"2020-04-12T23:32:33","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=10064"},"modified":"2023-05-27T23:29:14","modified_gmt":"2023-05-27T14:29:14","slug":"%e3%80%90typescript%e3%80%91%e3%83%87%e3%83%bc%e3%82%bf%e5%9e%8b","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=10064","title":{"rendered":"\u3010TypeScript\u3011\u300c\u5909\u6570\u300d\u3001\u300c\u5b9a\u6570\u300d\u3001\u300c\u30c7\u30fc\u30bf\u578b\u300d\u3001\u300c\u578b\u63a8\u8ad6\u300d\u3001\u300c\u914d\u5217\u300d"},"content":{"rendered":"<h2>\u57fa\u672c\u7684\u306a\u30c7\u30fc\u30bf\u578b<\/h2>\n<h3>boolean<\/h3>\n<p>\u771f\u507d\u5024(true\/false)\u3092\u6271\u3044\u307e\u3059\u3002<\/p>\n<h3>number<\/h3>\n<p>\u6570\u5024(\u6574\u6570\u3001\u6d6e\u52d5\u5c0f\u6570\u70b9\uff09\u3092\u6271\u3044\u307e\u3059\u3002<\/p>\n<h3>string<\/h3>\n<p>\u6587\u5b57\u5217\u3092\u6271\u3044\u307e\u3059\u3002<\/p>\n<h3>any<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>\u307e\u3060\u30c7\u30fc\u30bf\u578b\u304c\u78ba\u5b9a\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u3084\u5f97\u4f53\u306e\u3057\u308c\u306a\u3044\u7269\u306e\u5834\u5408<\/strong><\/span>\u306b\u66ab\u5b9a\u7684\u306b\u6c7a\u3081\u308b\u30c7\u30fc\u30bf\u578b\u3067\u3059\u3002\u53e4\u3044JavaScript\u30b3\u30fc\u30c9\u3092\u30ea\u30d7\u30ec\u30a4\u3059\u308b\u5834\u5408\u3068\u304b\u3067\u3082\u4f7f\u3063\u305f\u308a\u3057\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>\u672c\u6765\u3067\u3042\u308c\u3070\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3088\u3046\u306a\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3057\u3066\u3082\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u306a\u3044\u306e\u3067\u3001<\/strong><strong>\u57fa\u672c\u7684\u306b\u306f\u4f7f\u3044\u307e\u305b\u3093\u3002<\/strong><\/span>\u305f\u3060\u3001\u958b\u767a\u6642\u306b\u3069\u3046\u3057\u3066\u3082\u4f7f\u308f\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044\u3068\u3044\u3046\u5834\u5408\u3068\u304b\u3082\u767a\u751f\u3059\u308b\u53ef\u80fd\u6027\u3082\u3042\u308b\u306e\u3067\u305d\u306e\u5834\u5408\u306f\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<h2>\u5ba3\u8a00<\/h2>\n<p>\u30c7\u30fc\u30bf\u578b\u3092\u5909\u6570\u540d\u306e\u5f8c\u306b\u4ed8\u3051\u307e\u3059\u3002<span style=\"color: #ff0000;\"><strong>\u3082\u3057\u30c7\u30fc\u30bf\u578b\u3092\u7701\u7565\u3057\u305f\u5834\u5408\u306f\u578b\u63a8\u8ad6\u306b\u3088\u308a\u81ea\u52d5\u3067\u6c7a\u307e\u308a\u307e\u3059\u3002\u307e\u305f\u3001\u30c7\u30fc\u30bf\u578b\u3082\u4ee3\u5165\u3059\u308b\u5024\u3082\u7701\u7565\u3057\u305f\u5834\u5408\u3084JSON\u3092\u5909\u6570\u306e\u4e2d\u306b\u4ee3\u5165\u3057\u305f\u5834\u5408\u306fany\u578b\u306b\u306a\u308a\u307e\u3059\u3002<\/strong><\/span><\/p>\n<pre class=\"lang:default decode:true\">\/\/\u5909\u6570\u5ba3\u8a00\r\nlet \u5909\u6570\u540d: \u30c7\u30fc\u30bf\u578b = \u5024;\r\n\r\n\/\/string\r\nlet str:string = '\u6587\u5b57\u5217';\r\n\r\n\/\/number\r\nlet num:number = 3;\r\n\r\n\/\/boolean\r\nlet flg:boolean = true;\r\n\r\n\/\/any\u306b\u306a\u308b\u3002\r\nlet test;\r\n\r\n\/\/\u5b9a\u6570\u5ba3\u8a00\r\nconst \u5b9a\u6570\u540d: \u30c7\u30fc\u30bf\u578b = \u5024;\r\n\u304b<\/pre>\n<h3>\u578b\u63a8\u8ad6<\/h3>\n<p>\u4ee5\u4e0b\u306f\u3001\u7279\u306b\u578b\u306f\u5ba3\u8a00\u3057\u3066\u3044\u306a\u3044\u3067\u3059\u304c\u3001\u578b\u63a8\u8ad6\u3067boolean\u578b\u304c\u9078\u3070\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-17890\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2020\/04\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2022-09-19-11.14.13-300x104.png\" alt=\"\" width=\"300\" height=\"104\" srcset=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2020\/04\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2022-09-19-11.14.13-300x104.png 300w, http:\/\/www.code-magagine.com\/wp-content\/uploads\/2020\/04\/\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8-2022-09-19-11.14.13.png 460w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>\u57fa\u672c\u7684\u306b\u5197\u9577\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u578b\u63a8\u8ad6\u304c\u52b9\u304f\u5834\u5408\u306f\u4f7f\u3063\u305f\u65b9\u304c\u826f\u3044\u3068\u3044\u3046\u8003\u3048\u65b9\u3092\u3059\u308b\u4eba\u3082\u3044\u307e\u3059\u3002<\/p>\n<h2>\u914d\u5217<\/h2>\n<p>\u914d\u5217\u306f\u4ee5\u4e0b\u306e\uff12\u629e\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u914d\u5217\u30ea\u30c6\u30e9\u30eb([])<\/li>\n<li>Array&lt;\u30c7\u30fc\u30bf\u578b&gt;\u3092\u4f7f\u3046\u3002<\/li>\n<\/ul>\n<h3>string\u914d\u5217<\/h3>\n<p>\u3053\u3061\u3089\u306e\u65b9\u304c\u63a8\u5968\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">let array: string[] = ['a','b','c']<\/pre>\n<h3>Array&lt;\u30c7\u30fc\u30bf\u578b&gt;<\/h3>\n<p>\u3042\u307e\u308a\u63a8\u5968\u3055\u308c\u3066\u3044\u306a\u3044\u8a18\u8ff0\u65b9\u6cd5\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">let array: Array&lt;string&gt; = ['a','b','c']<\/pre>\n<h3>\u914d\u5217\u30ea\u30c6\u30e9\u30eb\u3068Array&lt;\u30c7\u30fc\u30bf\u578b&gt;\u306f\u9055\u3044\u306f\u3042\u308b\u304b\uff1f<\/h3>\n<p>\u6319\u52d5\u7684\u306a\u9055\u3044\u306f\u5168\u304f\u306a\u3044\u3067\u3059\u3002\u300c\u30b3\u30fc\u30c9\u4e0a\u306e\u610f\u5473\u300d\u3084\u300c\u30b3\u30f3\u30d1\u30a4\u30e9\u306e\u30c1\u30a7\u30c3\u30af\u5185\u5bb9\u300d\u3069\u3061\u3089\u3082\u5168\u304f\u540c\u3058\u6319\u52d5\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305f\u3060\u3001\u53ef\u8aad\u6027\u306f\u914d\u5217\u30ea\u30c6\u30e9\u30eb\u3092\u4f7f\u3063\u305f\u66f8\u304d\u65b9\u306e\u65b9\u304c\u8aad\u307f\u3084\u3059\u3044\u306e\u3067\u826f\u304f\u4f7f\u308f\u308c\u307e\u3059\u3002<\/p>\n<h3>\u30c7\u30fc\u30bf\u578b\u304c\u6df7\u5728\u3059\u308b\u914d\u5217<\/h3>\n<p>\u914d\u5217\u306e\u4e2d\u306e\u30c7\u30fc\u30bf\u578b\u3092\u8907\u6570\u6df7\u5728\u3055\u305b\u308b\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\uff08<span style=\"color: #ff0000;\"><strong>\u5171\u7528\u578b<\/strong><\/span>\u3068\u3044\u3046\u6587\u6cd5\u3082\u5408\u308f\u305b\u3066\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002\uff09<\/p>\n<pre class=\"lang:default decode:true\">let array: (number | string)[] = [1,2,'str'];<\/pre>\n<h3>any\u914d\u5217<\/h3>\n<pre class=\"lang:default decode:true \">let array = []<\/pre>\n","protected":false},"excerpt":{"rendered":"\u57fa\u672c\u7684\u306a\u30c7\u30fc\u30bf\u578b boolean \u771f\u507d\u5024(true\/false)\u3092\u6271\u3044\u307e\u3059\u3002 number \u6570\u5024(\u6574\u6570\u3001\u6d6e\u52d5\u5c0f\u6570\u70b9\uff09\u3092\u6271\u3044\u307e\u3059\u3002 string \u6587\u5b57\u5217\u3092\u6271\u3044\u307e\u3059\u3002 any \u307e\u3060\u30c7\u30fc\u30bf\u578b\u304c\u78ba\u5b9a\u3057\u3066\u3044\u306a\u3044\u5834\u5408\u3084\u5f97\u4f53\u306e\u3057\u308c\u306a\u3044 [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[101],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/10064"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10064"}],"version-history":[{"count":14,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/10064\/revisions"}],"predecessor-version":[{"id":20610,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/10064\/revisions\/20610"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10064"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}