{"id":6576,"date":"2020-04-02T15:00:29","date_gmt":"2020-04-02T06:00:29","guid":{"rendered":"https:\/\/blog.capilano-fw.com\/?p=6576"},"modified":"2020-04-02T16:28:51","modified_gmt":"2020-04-02T07:28:51","slug":"typescript%e3%81%ae%e9%96%a2%e6%95%b0%e3%80%81%e3%82%a4%e3%83%b3%e3%82%bf%e3%83%bc%e3%83%95%e3%82%a7%e3%82%a4%e3%82%b9%e3%80%81%e3%82%af%e3%83%a9%e3%82%b9%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9%e3%83%bb","status":"publish","type":"post","link":"https:\/\/blog.capilano-fw.com\/?p=6576","title":{"rendered":"TypeScript\u306e\u95a2\u6570\u3001\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3001\u30af\u30e9\u30b9\u306e\u4f7f\u3044\u65b9\u30fb\u5b9f\u4f8b\uff18\u4ef6"},"content":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u8a18\u4e8b\u300c<strong><a href=\"https:\/\/blog.capilano-fw.com\/?p=6527\">TypeScript\u306e\u578b\u5ba3\u8a00\u30fb\u516815\u5b9f\u4f8b<\/a><\/strong>\u300d\u3067\u306f<code>TypeScript<\/code>\u306e\u57fa\u672c\u3092\u77e5\u308b\u305f\u3081\u306b\u57fa\u672c\u4e2d\u306e\u57fa\u672c\u3067\u3042\u308b\u300c\u578b\u306e\u5ba3\u8a00\u300d\u3092\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u4eca\u56de\u3082\u57fa\u672c\u30c6\u30af\u30cb\u30c3\u30af\u306e\u3001<\/p>\n<p><strong style=\"font-size: 35px;\">\u95a2\u6570\u3001\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3001\u30af\u30e9\u30b9<\/strong><\/p>\n<p>\u306e\u4f7f\u3044\u65b9\u3092\u3054\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001<code>TypeScript<\/code>\u306f\u3001\u57fa\u672c\u7684\u306b<code>JavaScript<\/code>\u306e<code>ES6\uff08ES2015\uff09<\/code>\u306e\u66f8\u304d\u65b9\u3092\u8e0f\u8972\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001<strong><code>TypeScript<\/code>\u3060\u3051\u3067\u306a\u304f\u7d14\u7c8b\u306a<code>JavaScript<\/code>\u306e\u77e5\u8b58\u3068\u3057\u3066\u3082\u5206\u304b\u308a\u3084\u3059\u3044\u3088\u3046\u306b\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/strong><\/p>\n<p>\u305c\u3072\u697d\u3057\u307f\u306a\u304c\u3089\u3084\u3063\u3066\u307f\u307e\u3057\u3087\u3046\uff01\ud83d\ude0a\u2728<\/p>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4445 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_2.png\" alt=\"\" width=\"370\" height=\"310\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_2.png 370w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/08\/no_2-300x251.png 300w\" sizes=\"auto, (max-width: 370px) 100vw, 370px\" \/><strong style=\"font-size: 1rem;\">\u300c\u6700\u8fd1\u306fES6\u304c\u30e1\u30a4\u30f3\u3067\u3059\u2728\u300d<\/strong><\/p>\n<p><strong>\u958b\u767a\u74b0\u5883\uff1a<\/strong> TypeScript 3.8.3<\/p>\n<h1>\u95a2\u6570<\/h1>\n<h2>\u30c7\u30fc\u30bf\u578b\u3092\u6307\u5b9a\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u540d\u524d\u3068\u5e74\u9f62\u3092\u5165\u529b\u3057\u305f\u3089\u300c<strong>\u25cf\u25cf\u3055\u3093\uff08\u25b2\u25b2\u6b73\uff09<\/strong>\u300d\u3068\u8fd4\u3059\u95a2\u6570\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>function userInfo(name<strong>: string<\/strong>, age<strong>: number<\/strong>)<strong>: string<\/strong> {\r\n\r\n    return `${name} \u3055\u3093\uff08${age}\u6b73\uff09`;\r\n\r\n}\r\n\r\nconsole.log(\r\n    userInfo('\u592a\u90ce', 25)\r\n);<\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u3001\u578b\u306e\u5ba3\u8a00\u304c\u5165\u3063\u3066\u3044\u308b\u306e\u306f\u4ee5\u4e0b\uff12\u30f6\u6240\u3067\u3059\u3002<\/p>\n<ul>\n<li>\u5f15\u6570\u306e\u90e8\u5206\uff08\uff12\u3064\uff09<\/li>\n<li>\u8fd4\u308a\u5024\u306e\u90e8\u5206<\/li>\n<\/ul>\n<p>\u3053\u306e\u3088\u3046\u306b<strong>\u300c\u5165\u308b\u3068\u3053\u308d\uff06\u51fa\u308b\u3068\u3053\u308d\u300d\u3067\u578b\u5ba3\u8a00\u3092\u3059\u308b\u3053\u3068\u3067\u3088\u308a\u30a8\u30e9\u30fc\u3092\u6e1b\u3089\u3059\u3053\u3068\u306b\u3064\u306a\u304c\u308a\u307e\u3059\u3002<\/strong><\/p>\n<h2>\u5f15\u6570\u3092\u7701\u7565\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>\u540d\u524d\u306f\u5fc5\u9808\u3060\u3051\u3069\u3001\u5e74\u9f62\u306f\u4efb\u610f\u3067OK<\/strong>\u300d\u3068\u3044\u3046\u95a2\u6570\u3092\u4f5c\u308a\u305f\u3044\u5834\u5408\u3067\u3059\u3002<br \/>\n<span style=\"font-size: 1rem;\">\u3053\u306e\u5834\u5408\u3001\u5e74\u9f62\u306e\u5f15\u6570<\/span><code>age<\/code><span style=\"font-size: 1rem;\">\u306b<\/span><code>?<\/code><span style=\"font-size: 1rem;\">\u3092\u3064\u3051\u307e\u3059\u3002<\/span><\/p>\n<pre>function userInfo(name: string, <strong>age?<\/strong>: number): string {\r\n\r\n    let info = `${name} \u3055\u3093`;\r\n\r\n    if(age) { \/\/ \u5e74\u9f62\u304c\u3042\u308b\u5834\u5408\u3060\u3051\u5b9f\u884c\r\n\r\n        info += `\uff08${age}\u6b73\uff09`;\r\n\r\n    }\r\n\r\n    return info;\r\n\r\n}\r\n\r\nconsole.log(\r\n    <strong>userInfo('\u592a\u90ce')<\/strong> \/\/ \u300c\u592a\u90ce \u3055\u3093\u300d\r\n);\r\n\r\nconsole.log(\r\n    <strong>userInfo('\u592a\u90ce', 25)<\/strong> \/\/ \u300c\u592a\u90ce \u3055\u3093\uff0825\u6b73\uff09\u300d\r\n);<\/pre>\n<p>\u306a\u304a\u3001\u5f15\u6570\u304c\u7701\u7565\u3055\u308c\u305f\u5834\u5408\u4e2d\u8eab\u306f<code>undefined<\/code>\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u3064\u3051\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u540d\u524d\u306e\u5165\u529b\u304c\u306a\u3044\u5834\u5408\u3001\u4ee3\u308f\u308a\u306b\u300c<strong>\u533f\u540d\u5e0c\u671b<\/strong>\u300d\u304c\u5f15\u6570\u306b\u683c\u7d0d\u3055\u308c\u308b\u3088\u3046\u306b\u3057\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u5834\u5408\u3001\u5f15\u6570\u306b\u7d9a\u3044\u3066<code>=<\/code>\u3067\u521d\u671f\u5024\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n<pre>function userName(<strong>name: string = '\u533f\u540d\u5e0c\u671b'<\/strong>): string {\r\n\r\n    return `${name} \u3055\u3093`;\r\n\r\n}\r\n\r\nconsole.log(\r\n    <strong>userName() \/\/ \u300c\u533f\u540d\u5e0c\u671b \u3055\u3093\u300d<\/strong>\r\n);\r\nconsole.log(\r\n    <strong>userName('\u5c71\u7530\u592a\u90ce') \/\/ \u300c\u5c71\u7530\u592a\u90ce \u3055\u3093\u300d<\/strong>\r\n);<\/pre>\n<h2>\u5f15\u6570\u3092\u53ef\u5909\u306b\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5f15\u6570\u306e\u6570\u3092\u6307\u5b9a\u305b\u305a\u53ef\u5909\u306b\u3059\u308b\u5834\u5408\u3067\u3059\u3002<br \/>\n\u3053\u306e\u5834\u5408\u5f15\u6570\u306b<code>...<\/code>\u3092\u3064\u3051\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3068\u3057\u3066\u3001\u8da3\u5473\u3092\u6307\u5b9a\u3059\u308b\u5834\u5408\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>function myHobby(<strong>...hobbyNames: string[]<\/strong>): void {\r\n\r\n    console.log(hobbyNames);\r\n\r\n}\r\n\r\n<strong>myHobby('\u91ce\u7403', '\u30d4\u30a2\u30ce', '\u304a\u82b1', '\u30d0\u30fc\u30d9\u30ad\u30e5\u30fc');<\/strong> \/\/ \ud83d\udc48 \u5f15\u6570\u306f\u7121\u9650\u306b\u8ffd\u52a0\u3067\u304d\u307e\u3059\u3002<\/pre>\n<h2>\u95a2\u6570\u306b\u578b\u6307\u5b9a\u3059\u308b<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u300c<strong>\u4f55\u306e\u5546\u54c1\u3092\u3044\u304f\u3064\u6ce8\u6587\u3059\u308b\u304b\u2753<\/strong>\u300d\u3092\u6307\u5b9a\u3059\u308b\u95a2\u6570\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>let orderInfo: <strong>(name: string, count: number) =&gt; [string, number]<\/strong> =\r\n    function(productName: string, quantity: number): [string, number] {\r\n\r\n        return [productName, quantity];\r\n\r\n    };<\/pre>\n<p>\u5c11\u3057\u8907\u96d1\u3067\u3059\u304c\u3001\u3053\u306e\u5834\u5408\uff11\u884c\u76ee\u306e<strong>\u592a\u5b57<\/strong>\u306e\u90e8\u5206\u304c\u578b\u306e\u6307\u5b9a\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u6b21\u306e\u95a2\u6570\u306f<strong>\u300c\uff11\u3064\u76ee\u306e\u5f15\u6570\u306f\u6587\u5b57\u5217\u3001\uff12\u3064\u76ee\u304c\u6570\u5024\u3001\u305d\u3057\u3066\u8fd4\u308a\u5024\u306f\u914d\u5217\uff08\u6b63\u78ba\u306b\u306f\u3001\u6587\u5b57\u5217\u3068\u6570\u5024\u306e\u30bf\u30d7\u30eb\uff09\u300d<\/strong>\u3067\u3059\u3088\u3001\u3068\u3044\u3046\u6307\u5b9a\u3067\u3059\u3002<\/p>\n<h1>\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9<\/h1>\n<p>\u4f8b\u3048\u3070\u3001\u5f15\u6570\u304c\u305f\u304f\u3055\u3093\u5fc5\u8981\u306a\u5834\u5408\u3001<strong>\u30b3\u30fc\u30c9\u304c\u3054\u3061\u3083\u3054\u3061\u3083\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/strong><\/p>\n<pre>\/\/ \u5f15\u6570\u306e\u90e8\u5206\u304c\u9577\u3059\u304e\u3066\u898b\u306b\u304f\u3044\ud83d\ude2b\r\nfunction fullAddress(<strong>address: { zip: string, pref: string, city: string, street: string }<\/strong>): string {\r\n\r\n    return `\u3012${address.zip} ${address.pref} ${address.city} ${address.street}`;\r\n\r\n}<\/pre>\n<p><strong>\u305d\u3093\u306a\u5834\u5408\u306b\u5f79\u7acb\u3064\u306e\u304c\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3067\u3059\u3002<\/strong><br \/>\n\u5b9f\u969b\u306e\u4f8b\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><strong>interface Address { <\/strong>\/\/ \ud83d\udc48 \u4f4f\u6240\u306e\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\r\n<strong>    zip: string,<\/strong>\r\n<strong>    pref: string,<\/strong>\r\n<strong>    city: string,<\/strong>\r\n<strong>    street: string<\/strong>\r\n<strong>}<\/strong>\r\n\r\nfunction fullAddress(<strong>address: Address<\/strong>): string { \/\/ \ud83d\udc48 \u3053\u3053\u3067\u6307\u5b9a\r\n\r\n    return `\u3012${address.zip} ${address.pref} ${address.city} ${address.street}`;\r\n\r\n}<\/pre>\n<p>\u3064\u307e\u308a\u3001\u5f15\u6570\u306e\u90e8\u5206\u3092\u5225\u306e\u5834\u6240\u3067\u5b9a\u7fa9\u3059\u308b\u306e\u3067<strong>\u30b9\u30c3\u30ad\u30ea\u3057\u305f\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3053\u3068\u304c\u3067\u304d\u308b\u3068\u3044\u3046\u308f\u3051\u3067\u3059\u3002<\/strong><\/p>\n<p>\u3057\u304b\u3082\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u306f\u4f7f\u3044\u307e\u308f\u3057\u304c\u3067\u304d\u308b\u306e\u3067\u4e00\u5ea6\u5b9a\u7fa9\u3057\u3066\u304a\u304f\u3068\u5f8c\u3067\u30e9\u30af\u304c\u3067\u304d\u307e\u3059\u306d\ud83d\ude0a\u2728<\/p>\n<h1>\u30af\u30e9\u30b9<\/h1>\n<h2>\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h2>\n<p>\u57fa\u672c\u7684\u306a\u30af\u30e9\u30b9\u306e\u4f7f\u3044\u65b9\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<pre>class User {\r\n\r\n    <strong>private name: string;<\/strong> \/\/ \ud83d\udc48 \u30af\u30e9\u30b9\u5185\u304b\u3089\u3057\u304b\u53d6\u5f97\u3067\u304d\u306a\u3044\r\n\r\n    constructor(name: string) {\r\n\r\n        this.name = name;\r\n\r\n    }\r\n\r\n    <strong>public message(): string { <\/strong>\/\/ \ud83d\udc48 \u3069\u3053\u304b\u3089\u3067\u3082\u30a2\u30af\u30bb\u30b9\u53ef<strong>\r\n\r\n        return `\u3053\u3093\u306b\u3061\u306f\u3001${this.name} \u3055\u3093\uff01`;\r\n\r\n    }<\/strong>\r\n\r\n}\r\n\r\nconst user = new User('\u5c71\u7530\u592a\u90ce');\r\nconsole.log(\r\n    user.message()\r\n);<\/pre>\n<p>\u3053\u306e\u306a\u304b\u3067\u91cd\u8981\u306a\u306e\u306f\u30a2\u30af\u30bb\u30b9\u30fb\u30b9\u30b3\u30fc\u30d7\u3067\u3059\u3002<\/p>\n<p><strong>\u30a2\u30af\u30bb\u30b9\u30fb\u30b9\u30b3\u30fc\u30d7\u3068\u306f\u3001\u5909\u6570\u3084\u30e1\u30bd\u30c3\u30c9\u306e\u30a2\u30af\u30bb\u30b9\u7bc4\u56f2\u3092\u6307\u5b9a\u3059\u308b\u3082\u306e<\/strong>\u3067\u3001\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>private\uff1a \u305d\u306e\u30af\u30e9\u30b9\u5185\u3060\u3051<\/li>\n<li>protected\uff1a \u305d\u306e\u30af\u30e9\u30b9\uff06\u7d99\u627f\u3055\u308c\u305f\u30af\u30e9\u30b9\u3060\u3051<\/li>\n<li>public\uff1a \u3069\u3053\u304b\u3089\u3067\u3082OK<\/li>\n<\/ul>\n<p>\u3064\u307e\u308a\u4eca\u56de\u306e\u4f8b\u3067\u8a00\u3046\u3068\u3001<strong>\u5909\u6570<code>name<\/code>\u306f<code>private<\/code>\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u30af\u30e9\u30b9\u306e\u4e2d\u304b\u3089\u3057\u304b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u307e\u305b\u3093\u3002<\/strong>\uff08<code>user<\/code>\u304b\u3089\u306f\u30a2\u30af\u30bb\u30b9\u3067\u304d\u306a\u3044\uff09<\/p>\n<p>\u9006\u306b<strong><code>message()<\/code>\u306f\u3001<code>public<\/code>\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001\u3069\u3053\u304b\u3089\u3067\u3082\u30a2\u30af\u30bb\u30b9\u304c\u3067\u304d\u307e\u3059\u3002<\/strong><\/p>\n<h2>\u30af\u30e9\u30b9\u306e\u7d99\u627f\uff08\u62e1\u5f35\uff09<\/h2>\n<p>\u4f8b\u3048\u3070\u3001\u5148\u307b\u3069\u306e<code>User<\/code>\u30af\u30e9\u30b9\u306b\u5e74\u9f62\u3092\u30bb\u30c3\u30c8\u3059\u308b\u30e1\u30bd\u30c3\u30c9<code>setAge()<\/code>\u3092\u8ffd\u52a0\u3057\u305f\u3044\u5834\u5408\u3067\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u76f4\u63a5<code>User<\/code>\u30af\u30e9\u30b9\u306b\u30b3\u30fc\u30c9\u3092\u8db3\u3057\u3066\u3082\u3044\u3044\u3067\u3059\u304c\u3001\u3082\u3057\u7ba1\u7406\u8005\u30e6\u30fc\u30b6\u30fc\u3060\u3051\u306b\u5e74\u9f62\u60c5\u5831\u304c\u5fc5\u8981\u306a\u5834\u5408\u3001<strong><code>User<\/code>\u3092\u7d99\u627f\u3057\u305f<code>Admin<\/code>\u30af\u30e9\u30b9\u3092\u3064\u304f\u3063\u3066\u304a\u3051\u3070\u9593\u9055\u3063\u305f\u4f7f\u3044\u65b9\u304c\u6e1b\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/strong><\/p>\n<p>\u305d\u3053\u3067\u3001<code>User<\/code>\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3057\u3066<code>Admin<\/code>\u30af\u30e9\u30b9\u3092\u3064\u304f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><strong>\u3010\uff11\uff0eUser\u30af\u30e9\u30b9\u3011<\/strong><\/p>\n<pre>class User {\r\n\r\n    <strong>protected<\/strong> name: string; \/\/ \ud83d\udc48 \u3053\u306e\u30af\u30e9\u30b9\u3068\u7d99\u627f\u30af\u30e9\u30b9\u306a\u3089\u30a2\u30af\u30bb\u30b9\u53ef\r\n\r\n    constructor(name: string) {\r\n\r\n        this.name = name;\r\n\r\n    }\r\n\r\n    public message(): string {\r\n\r\n        return `\u3053\u3093\u306b\u3061\u306f\u3001${this.name} \u3055\u3093\uff01`;\r\n\r\n    }\r\n\r\n}<\/pre>\n<p>\u307e\u305a\u306f<code>User<\/code>\u30af\u30e9\u30b9\u3067\u3059\u304c\uff11\u30f5\u6240\u3060\u3051\u5909\u66f4\u3057\u3066\u304a\u304f\u90e8\u5206\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u305d\u308c\u306f\u5909\u6570<code>name<\/code>\u306e\u30a2\u30af\u30bb\u30b9\u30fb\u30b9\u30b3\u30fc\u30d7\u3067\u3059\u3002<\/p>\n<p>\u5148\u307b\u3069\u306f<code>private<\/code>\u3067\u3057\u305f\u304c\u3001\u4eca\u56de\u306f\u30a2\u30af\u30bb\u30b9\u7bc4\u56f2\u3092<code>protected<\/code>\u306b\u3057\u307e\u3059\u3002<br \/>\n\u3053\u308c\u3067\u3001\u7d99\u627f\u3055\u308c\u305f\u5148\u306e\u30af\u30e9\u30b9<code>Admin<\/code>\u304b\u3089\u3067\u3082\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><strong>\u3010\uff12\uff0eAdmin\u30af\u30e9\u30b9\u3011<\/strong><\/p>\n<p>\u3067\u306f\u3001<code>User<\/code>\u3092\u62e1\u5f35\u3057\u305f<code>Admin<\/code>\u30af\u30e9\u30b9\u3067\u3059\u3002<\/p>\n<pre>class Admin <strong>extends User<\/strong> { \/\/ \ud83d\udc48 \u7d99\u627f\u3092\u6307\u5b9a\r\n\r\n    private age: number = -1;\r\n\r\n    constructor(name: string) {\r\n\r\n        super(name);\r\n\r\n    }\r\n\r\n<strong>    public setAge(age: number): void {<\/strong>\r\n\r\n<strong>        this.age = age;<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n    <strong>public message(): string {<\/strong> \/\/ \ud83d\udc48 \u5185\u5bb9\u3092\u4e0a\u66f8\u304d\r\n\r\n<strong>        return `\u3053\u3093\u306b\u3061\u306f\u3001${this.name}\uff08${this.age}\u6b73\uff09 \u3055\u3093\uff01`;<\/strong>\r\n\r\n<strong>    }<\/strong>\r\n\r\n}<\/pre>\n<p>\u3053\u306e\u4e2d\u3067\u91cd\u8981\u306a\u306e\u306f\u3001<code>extends User<\/code>\u3067\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3057\u3066\u3044\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001<code>Admin<\/code>\u3060\u3051\u306b\u5fc5\u8981\u306a<code>setAge()<\/code>\u3092\u8ffd\u52a0\u3057\u3001<strong>\u3059\u3067\u306b\u5b58\u5728\u3057\u3066\u3044\u308b\u540c\u540d\u306e\u30e1\u30bd\u30c3\u30c9<code>message()<\/code>\u3092\u3042\u3048\u3066\u8a2d\u7f6e\u3057\u3066\u5185\u5bb9\u3092\u4e0a\u66f8\u304d\u3057\u3066\u3044\u307e\u3059\u3002<\/strong><\/p>\n<p>\u5b9f\u969b\u306e\u4f7f\u3044\u65b9\u306f\u3053\u3046\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre>const admin = new Admin('\u5c71\u7530\u592a\u90ce');\r\nadmin.setAge(25);\r\n\r\nconsole.log(\r\n    admin.message() \/\/ \u300c\u3053\u3093\u306b\u3061\u306f\u3001\u5c71\u7530\u592a\u90ce\uff0825\u6b73\uff09 \u3055\u3093\uff01\u300d\r\n);<\/pre>\n<h1>\u304a\u308f\u308a\u306b<\/h1>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u4eca\u56de\u306f<code>TypeScript<\/code>\u306e\u95a2\u6570\u3001\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3001\u30af\u30e9\u30b9\u306e\u4f7f\u3044\u65b9\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u306a\u304a\u3001\u3053\u308c\u306f<code>TypeScript<\/code>\u3060\u3051\u3067\u306f\u306a\u3044\u3067\u3059\u304c\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\uff11\u3064\u306e\u8a00\u8a9e\u3092\u30de\u30b9\u30bf\u30fc\u3057\u3066\u304a\u3051\u3070\u3001<strong>\u4ed6\u306e\u3082\u306e\u3067\u3082\u300c\u6a19\u6e96\u8a9e\u3068\u95a2\u897f\u5f01\u300d\u3050\u3089\u3044\u306e\u9055\u3044\u306a\u306e\u3067\u3001\u6839\u672c\u306f\u540c\u3058\u306a\u3093\u3060\u306a\u3001\u3068\u611f\u3058\u3066\u3044\u307e\u3059\u3002<\/strong><\/p>\n<p>\u3068\u3044\u3046\u306e\u3082\u3001\u4eca\u56de\u306e\u30af\u30e9\u30b9\u3067\u4f7f\u3063\u305f<code>\u30a2\u30af\u30bb\u30b9\u30fb\u30b9\u30b3\u30fc\u30d7<\/code>\u306f<code>PHP<\/code>\u306b\u3082\u3042\u308a\u307e\u3059\u3057\u3001\u95a2\u6570\u306e\u578b\u5ba3\u8a00\u306f<code>Java<\/code>\u305d\u3063\u304f\u308a\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u305d\u306e\u305f\u3081\u3001\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u8005\u306e\u65b9\u3005\u306f<strong>\u6697\u8a18\u3068\u3044\u3046\u3088\u308a\u306f\u6839\u672c\u7684\u306a\u69cb\u9020\u3092\u610f\u8b58\u3057\u306a\u304c\u3089\u52c9\u5f37\u3057\u3066\u3044\u304f\u3068\u5f8c\u3005\u697d\u304c\u3067\u304d\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/strong><\/p>\n<p>\u305c\u3072\u3001\u305d\u3093\u306a\u611f\u3058\u3067\u30c1\u30e3\u30ec\u30f3\u30b8\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u306d\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u301c\u2757<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3467 aligncenter\" src=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_9.png\" alt=\"\" width=\"216\" height=\"320\" srcset=\"https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_9.png 216w, https:\/\/blog.capilano-fw.com\/wp-content\/uploads\/2019\/04\/no_9-203x300.png 203w\" sizes=\"auto, (max-width: 216px) 100vw, 216px\" \/><\/p>\n<p style=\"text-align: center;\">\u300c\u30b3\u30ed\u30ca\u306e\u5f71\u97ff\u3067\u5916\u51fa\u3092\u81ea\u7c9b\u4e2d\u3002<br \/>\n\u30af\u30e9\u30d5\u30c8\u30d3\u30fc\u30eb\u304c\u98f2\u307f\u306b\u884c\u3051\u306a\u3044\ud83d\ude13<br \/>\n\u30fb\u30fb\u30fb\u4eca\u306f\u30ac\u30de\u30f3\u2757\u300d<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3055\u3066\u3055\u3066\u3001\u524d\u56de\u8a18\u4e8b\u300cTypeScript\u306e\u578b\u5ba3\u8a00\u30fb\u516815\u5b9f\u4f8b\u300d\u3067\u306fTypeScript\u306e\u57fa\u672c\u3092\u77e5\u308b\u305f\u3081\u306b\u57fa\u672c\u4e2d\u306e\u57fa\u672c\u3067\u3042\u308b\u300c\u578b\u306e\u5ba3\u8a00\u300d\u3092\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002 \u305d\u3057 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.capilano-fw.com\/?p=6576\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;TypeScript\u306e\u95a2\u6570\u3001\u30a4\u30f3\u30bf\u30fc\u30d5\u30a7\u30a4\u30b9\u3001\u30af\u30e9\u30b9\u306e\u4f7f\u3044\u65b9\u30fb\u5b9f\u4f8b\uff18\u4ef6&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":6639,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[209],"class_list":["post-6576","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-typescript"],"_links":{"self":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/6576","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6576"}],"version-history":[{"count":62,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/6576\/revisions"}],"predecessor-version":[{"id":6641,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/posts\/6576\/revisions\/6641"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=\/wp\/v2\/media\/6639"}],"wp:attachment":[{"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6576"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.capilano-fw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}