{"id":84507,"date":"2025-02-26T08:58:27","date_gmt":"2025-02-26T01:58:27","guid":{"rendered":"https:\/\/itviec.com\/blog\/?p=84507"},"modified":"2025-02-26T08:58:27","modified_gmt":"2025-02-26T01:58:27","slug":"typescript-la-gi","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/typescript-la-gi\/","title":{"rendered":"TypeScript l\u00e0 g\u00ec: T\u00ecm hi\u1ec3u chi ti\u1ebft v\u1ec1 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a TypeScript"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/#TypeScript_la_gi\" >TypeScript l\u00e0 g\u00ec?\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/#Diem_noi_bat_cua_TypeScript_la_gi\" >\u0110i\u1ec3m n\u1ed5i b\u1eadt c\u1ee7a TypeScript l\u00e0 g\u00ec?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/#Uu_va_nhuoc_diem_cua_TypeScript_la_gi\" >\u01afu v\u00e0 nh\u01b0\u1ee3c \u0111i\u1ec3m c\u1ee7a TypeScript l\u00e0 g\u00ec?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/#He_thong_go_cua_TypeScript\" >H\u1ec7 th\u1ed1ng g\u00f5 c\u1ee7a TypeScript<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/#Lap_trinh_huong_doi_tuong_Object-Oriented_Programming_%E2%80%93_OOP_trong_TypeScript\" >L\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (Object-Oriented Programming &#8211; OOP) trong TypeScript\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/#Moi_quan_he_giua_TypeScript_vs_JavaScript\" >M\u1ed1i quan h\u1ec7 gi\u1eefa TypeScript vs JavaScript\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/#Cau_hoi_thuong_gap_ve_TypeScript_la_gi\" >C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 TypeScript l\u00e0 g\u00ec<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/#Tong_ket_TypeScript_la_gi\" >T\u1ed5ng k\u1ebft TypeScript l\u00e0 g\u00ec<\/a><\/li><\/ul><\/nav><\/div>\n<p><em><strong>TypeScript l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh m\u1edf r\u1ed9ng c\u1ee7a JavaScript, gi\u00fap m\u00e3 ngu\u1ed3n d\u1ec5 \u0111\u1ecdc v\u00e0 h\u1ea1n ch\u1ebf l\u1ed7i nh\u1edd c\u01a1 ch\u1ebf ki\u1ec3m tra ki\u1ec3u t\u0129nh. L\u00e0 ng\u00f4n ng\u1eef \u0111\u01b0\u1ee3c ph\u00e1t tri\u1ec3n b\u1edfi Microsoft, TypeScript ng\u00e0y c\u00e0ng ph\u1ed5 bi\u1ebfn trong vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng web hi\u1ec7n \u0111\u1ea1i. V\u1eady TypeScript l\u00e0 g\u00ec v\u00e0 hi\u1ec7u qu\u1ea3 ho\u1ea1t \u0111\u1ed9ng c\u1ee7a ch\u00fang nh\u01b0 th\u1ebf n\u00e0o?<\/strong><\/em><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ecdc b\u00e0i vi\u1ebft sau \u0111\u00e2y \u0111\u1ec3 hi\u1ec3u r\u00f5 h\u01a1n v\u1ec1:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ed5ng quan v\u1ec1 nh\u1eefng \u0111i\u1ec3m m\u1ea1nh v\u00e0 c\u00f4ng d\u1ee5ng n\u1ed5i b\u1eadt c\u1ee7a TypeScript l\u00e0 g\u00ec<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">H\u1ec7 th\u1ed1ng g\u00f5 c\u1ee7a TypeScript<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">TypeScript Object-Oriented Programming (OOP)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">S\u1ef1 kh\u00e1c bi\u1ec7t gi\u1eefa TypeScript vs JavaScript<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"TypeScript_la_gi\"><\/span><b>TypeScript l\u00e0 g\u00ec?\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">TypeScript l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh m\u00e3 ngu\u1ed3n m\u1edf \u0111\u01b0\u1ee3c ph\u00e1t tri\u1ec3n v\u00e0 duy tr\u00ec b\u1edfi Microsoft t\u1eeb n\u0103m 2012. TypeScript \u0111\u01b0\u1ee3c xem l\u00e0 m\u1ed9t\u00a0<a href=\"https:\/\/www.typescriptlang.org\/\" target=\"_blank\" rel=\"noopener\">ph\u1ea7n m\u1edf r\u1ed9ng c\u1ee7a JavaScript<\/a>, s\u1eed d\u1ee5ng c\u00fa ph\u00e1p c\u1ee7a JavaScript v\u00e0 b\u1ed5 sung th\u00eam m\u1ed9t s\u1ed1 t\u00ednh n\u0103ng nh\u01b0 ki\u1ec3u t\u0129nh, class, h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng,\u2026<\/span><\/p>\n<p><span style=\"font-weight: 400;\">M\u00e3 TypeScript kh\u00f4ng \u0111\u01b0\u1ee3c tr\u00ecnh duy\u1ec7t di\u1ec5n gi\u1ea3i tr\u1ef1c ti\u1ebfp \u0111\u1ec3 hi\u1ec3n th\u1ecb tr\u00ean web n\u00ean c\u1ea7n ph\u1ea3i bi\u00ean d\u1ecbch m\u00e3 TypeScript th\u00e0nh m\u00e3 JavaScript thu\u1ea7n t\u00fay. Ch\u00ednh v\u00ec v\u1eady, khi l\u1eadp tr\u00ecnh TypeScript s\u1ebd c\u1ea7n \u0111\u1ebfn Tr\u00ecnh bi\u00ean d\u1ecbch TypeScript (tsc) \u0111\u1ec3 chuy\u1ec3n \u0111\u1ed5i m\u00e3 sang JavaScript d\u1ec5 d\u00e0ng h\u01a1n.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">D\u01b0\u1edbi \u0111\u00e2y l\u00e0 \u0111o\u1ea1n code HTML c\u00f3 g\u1ecdi v\u00e0 s\u1eed d\u1ee5ng file types.js:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">&lt;!DOCTYPE html&gt;<\/span>\r\n<span style=\"font-weight: 400;\">&lt;html&gt;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">&lt;body&gt;<\/span>\r\n<span style=\"font-weight: 400;\">&lt;h2&gt;ITviec&lt;\/h2&gt;<\/span>\r\n<span style=\"font-weight: 400;\">&lt;p&gt;ITviec Blog - \u00dd t\u01b0\u1edfng ph\u00e1t tri\u1ec3n s\u1ef1 nghi\u1ec7p IT c\u1ee7a b\u1ea1n&lt;\/p&gt;<\/span>\r\n<span style=\"font-weight: 400;\">&lt;script src=\"types.js\"&gt;&lt;\/script&gt;<\/span>\r\n<span style=\"font-weight: 400;\">&lt;\/body&gt;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">&lt;\/html&gt;<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">T\u1ea1o file types.ts v\u00e0 th\u00eam \u0111o\u1ea1n code sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">let myString: string;<\/span>\r\n<span style=\"font-weight: 400;\">myString = 'Hello from ts';<\/span>\r\n<span style=\"font-weight: 400;\">console.log(myString);<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Sau khi c\u00f3 file types.ts v\u00e0 file HTML tr\u00ean, b\u1ea1n s\u1ebd c\u1ea7n d\u1ecbch sang m\u00e3 TypeScript. Th\u1ef1c hi\u1ec7n nh\u1eadp l\u1ec7nh nh\u01b0 sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">tsc types.ts<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Khi bi\u00ean d\u1ecbch th\u00e0nh c\u00f4ng, s\u1ebd t\u1ea1o \u0111\u01b0\u1ee3c m\u1ed9t file JavaScript c\u00f9ng t\u00ean v\u00e0 ph\u1ea7n m\u1edf r\u1ed9ng .js, t\u1ee9c l\u00e0 type.js ch\u1ee9a m\u00e3 \u0111\u00e3 bi\u00ean d\u1ecbch trong c\u00f9ng th\u01b0 m\u1ee5c. B\u00e2y gi\u1edd khi ch\u1ea1y file HTML s\u1ebd hi\u1ec3n th\u1ecb k\u1ebft qu\u1ea3 l\u00e0 m\u00e3 JavaScript chu\u1ea9n.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Diem_noi_bat_cua_TypeScript_la_gi\"><\/span><b>\u0110i\u1ec3m n\u1ed5i b\u1eadt c\u1ee7a TypeScript l\u00e0 g\u00ec?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>Ki\u1ec3u t\u0129nh\u00a0<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3u t\u0129nh c\u1ee7a TypeScript cho ph\u00e9p b\u1ea1n ki\u1ec3m tra v\u00e0 g\u00e1n ki\u1ec3u cho c\u00e1c bi\u1ebfn, tham s\u1ed1 v\u00e0 gi\u00e1 tr\u1ecb tr\u1ea3 v\u1ec1 c\u1ee7a h\u00e0m. \u0110\u1ed3ng th\u1eddi, ki\u1ec3u t\u0129nh t\u00f9y ch\u1ecdn c\u0169ng gi\u00fap ng\u0103n ng\u1eeba l\u1ed7i v\u00e0 c\u1ea3i thi\u1ec7n m\u00e3 d\u1ec5 \u0111\u1ecdc h\u01a1n.\u00a0<\/span><\/p>\n<h3><b>\u0110\u1ed1i t\u01b0\u1ee3ng d\u1ef1a tr\u00ean l\u1edbp (Class-based Object)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">M\u1ed9t trong nh\u1eefng t\u00ednh n\u0103ng n\u1ed5i b\u1eadt c\u1ee7a TypeScript l\u00e0 h\u1ed7 tr\u1ee3 cho c\u00e1c l\u1edbp. Kh\u00f4ng gi\u1ed1ng nh\u01b0 c\u00e1ch ti\u1ebfp c\u1eadn d\u1ef1a tr\u00ean nguy\u00ean m\u1eabu c\u1ee7a JavaScript, TypeScript cho ph\u00e9p b\u1ea1n vi\u1ebft m\u00e3 h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng. B\u1ea1n c\u00f3 th\u1ec3 t\u1ea1o l\u1edbp (class), \u0111\u1ecbnh ngh\u0129a h\u00e0m v\u00e0 s\u1eed d\u1ee5ng c\u00e1c tr\u00ecnh s\u1eeda \u0111\u1ed5i truy c\u1eadp (public, private, protected).\u00a0<\/span><\/p>\n<h3><b>M\u00f4-\u0111un<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">TypeScript s\u1eed d\u1ee5ng c\u00e1c m\u00f4-\u0111un \u0111\u1ec3 s\u1eafp x\u1ebfp m\u00e3 th\u00e0nh c\u00e1c ph\u1ea7n nh\u1ecf h\u01a1n v\u00e0 c\u00f3 th\u1ec3 t\u00e1i s\u1eed d\u1ee5ng. Kh\u1ea3 n\u0103ng m\u00f4-\u0111un n\u00e0y c\u1ee7a TypeScript gi\u00fap n\u00e2ng cao kh\u1ea3 n\u0103ng b\u1ea3o tr\u00ec v\u00e0 s\u1ef1 ph\u1ed1i h\u1ee3p gi\u1eefa c\u00e1c th\u00e0nh vi\u00ean trong t\u00ednh ch\u1ea5t d\u1ef1 \u00e1n l\u1edbn.\u00a0<\/span><\/p>\n<h3><b>T\u00ednh n\u0103ng ES6<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">L\u00e0 m\u1ed9t ng\u00f4n ng\u1eef m\u1edf r\u1ed9ng c\u1ee7a JavaScript n\u00ean TypeScript c\u0169ng s\u1eed d\u1ee5ng c\u00e1c t\u00ednh n\u0103ng c\u1ee7a ECMAScript 6 (hay c\u00f2n g\u1ecdi l\u00e0 ES6). N\u1ebfu b\u1ea1n \u0111\u00e3 s\u1eed d\u1ee5ng quen thu\u1ed9c v\u1edbi c\u00fa ph\u00e1p c\u1ee7a ES6 nh\u01b0 h\u00e0m m\u0169i t\u00ean, k\u00fd t\u1ef1 m\u1eabu,&#8230; th\u00ec b\u1ea1n s\u1ebd c\u1ea3m th\u1ea5y tho\u1ea3i m\u00e1i v\u00e0 kh\u00f4ng qu\u00e1 kh\u00f3 kh\u0103n khi b\u1eaft \u0111\u1ea7u s\u1eed d\u1ee5ng TypeScript.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Uu_va_nhuoc_diem_cua_TypeScript_la_gi\"><\/span><b>\u01afu v\u00e0 nh\u01b0\u1ee3c \u0111i\u1ec3m c\u1ee7a TypeScript l\u00e0 g\u00ec?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">L\u00e0 m\u1ed9t ng\u00f4n ng\u1eef m\u1edf r\u1ed9ng c\u1ee7a JavaScript n\u00ean TypeScript c\u0169ng s\u1edf h\u1eefu c\u00e1c \u01b0u \u0111i\u1ec3m ch\u00ednh c\u1ee7a JavaScript. \u0110\u1ed3ng th\u1eddi cung c\u1ea5p c\u00e1c l\u1ee3i \u00edch b\u1ed5 sung \u0111\u1ebfn t\u1eeb ki\u1ec3u t\u0129nh v\u00e0 kh\u00e1i ni\u1ec7m kh\u00e1c d\u00e0nh ri\u00eang cho TypeScript.\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>S\u1eeda l\u1ed7i nhanh:<\/b><span style=\"font-weight: 400;\"> TypeScript c\u00f3 th\u1ec3 ph\u00e1t hi\u1ec7n c\u00e1c l\u1ed7i \u1edf giai \u0111o\u1ea1n bi\u00ean d\u1ecbch gi\u00fap ti\u1ebft ki\u1ec7m th\u1eddi gian cho l\u1eadp tr\u00ecnh vi\u00ean v\u00e0 cho ph\u00e9p h\u1ecd t\u1eadp trung v\u00e0o vi\u1ec7c s\u1eeda ch\u1eefa c\u00e1c l\u1ed7i trong logic.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Kh\u1ea3 n\u0103ng d\u1ef1 \u0111o\u00e1n:<\/b><span style=\"font-weight: 400;\"> N\u1ebfu m\u1ed9t bi\u1ebfn \u0111\u01b0\u1ee3c khai b\u00e1o d\u01b0\u1edbi d\u1ea1ng m\u1ed9t chu\u1ed7i, TypeScript s\u1ebd lu\u00f4n l\u00e0 m\u1ed9t chu\u1ed7i v\u00e0 s\u1ebd kh\u00f4ng bi\u1ebfn th\u00e0nh Boolean. \u0110i\u1ec1u n\u00e0y l\u00e0m t\u0103ng kh\u1ea3 n\u0103ng c\u00e1c ch\u1ee9c n\u0103ng ho\u1ea1t \u0111\u1ed9ng theo c\u00e1ch d\u1ef1 \u0111\u1ecbnh ban \u0111\u1ea7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u00e1i c\u1ea5u tr\u00fac m\u00e3:<\/b><span style=\"font-weight: 400;\"> TypeScript gi\u00fap qu\u00e1 tr\u00ecnh t\u00e1i c\u1ea5u tr\u00fac ho\u1eb7c c\u1eadp nh\u1eadt \u1ee9ng d\u1ee5ng ho\u1ea1t \u0111\u1ed9ng tr\u01a1n tru m\u00e0 v\u1eabn gi\u1eef \u0111\u01b0\u1ee3c c\u01a1 s\u1edf m\u00e3 ban \u0111\u1ea7u. B\u00ean c\u1ea1nh \u0111\u00f3, TypeScript c\u0169ng c\u00f3 th\u1ec3 ph\u00e1t hi\u1ec7n l\u1ed7i t\u1ef1 \u0111\u1ed9ng, gi\u00fap \u0111\u01a1n gi\u1ea3n ho\u00e1 v\u00e0 t\u0103ng t\u1ed1c t\u00e1i c\u1ea5u tr\u00fac m\u00e3. \u0110i\u1ec1u n\u00e0y s\u1ebd \u0111\u1eb7c bi\u1ec7t c\u00f3 l\u1ee3i n\u1ebfu b\u1ea1n x\u1eed l\u00fd ph\u1ea7n l\u1edbn c\u1ee7a c\u01a1 s\u1edf m\u00e3.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u01b0\u01a1ng th\u00edch \u0111a n\u1ec1n t\u1ea3ng:<\/b><span style=\"font-weight: 400;\"> M\u1ecdi thi\u1ebft b\u1ecb, n\u1ec1n t\u1ea3ng ho\u1eb7c tr\u00ecnh duy\u1ec7t t\u01b0\u01a1ng th\u00edch JavaScript c\u0169ng ho\u1ea1t \u0111\u1ed9ng \u0111\u01b0\u1ee3c v\u1edbi TypeScript, sau khi tr\u00ecnh bi\u00ean d\u1ecbch chuy\u1ec3n \u0111\u1ed5i m\u00e3 th\u00e0nh JavaScript.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>H\u1ed7 tr\u1ee3 c\u00f4ng c\u1ee5:<\/b><span style=\"font-weight: 400;\"> Cung c\u1ea5p c\u00e1c c\u00f4ng c\u1ee5 ph\u00e1t tri\u1ec3n tuy\u1ec7t v\u1eddi nh\u01b0 IntelliSense, g\u1ee3i \u00fd th\u1ef1c khi vi\u1ebft m\u00e3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>IDE:<\/b><span style=\"font-weight: 400;\"> N\u00e2ng cao tr\u1ea3i nghi\u1ec7m c\u1ee7a l\u1eadp tr\u00ecnh vi\u00ean v\u1edbi m\u00f4-\u0111un tr\u00ecnh ch\u1ec9nh s\u1eeda v\u01b0\u1ee3t tr\u1ed9i.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u00e0i li\u1ec7u API:<\/b><span style=\"font-weight: 400;\"> \u0110\u1ea3m b\u1ea3o t\u00e0i li\u1ec7u t\u1ed1t h\u01a1n cho c\u00e1c API \u0111\u1ed3ng b\u1ed9 v\u1edbi m\u00e3 ngu\u1ed3n, c\u00f3 kh\u1ea3 n\u0103ng gi\u1ea3m l\u1ed7i.\u00a0<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">B\u00ean c\u1ea1nh \u0111\u00f3, m\u1ed9t s\u1ed1 \u0111i\u1ec3m y\u1ebfu c\u1ee7a TypeScript l\u00e0 g\u00ec?\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">M\u1ed9t s\u1ed1 l\u1eadp tr\u00ecnh vi\u00ean th\u00e0nh th\u1ea1o C#, C++ ho\u1eb7c Java cho r\u1eb1ng TypeScript kh\u00f4ng ph\u1ea3i l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef \u0111\u00e1nh m\u00e1y t\u0129nh th\u1ef1c s\u1ef1.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">M\u1ea5t nhi\u1ec1u th\u1eddi gian bi\u1ebfn d\u1ecbch m\u00e3.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Y\u00eau c\u1ea7u file \u0111\u1ecbnh ngh\u0129a cho th\u01b0 vi\u1ec7n c\u1ee7a b\u00ean th\u1ee9 ba, c\u00f3 th\u1ec3 kh\u00f4ng ph\u1ea3i l\u00fac n\u00e0o c\u0169ng c\u00f3 s\u1eb5n ho\u1eb7c c\u00f3 ch\u1ea5t l\u01b0\u1ee3ng t\u1ed1t.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u1ea7n c\u00f3 b\u01b0\u1edbc bi\u00ean d\u1ecbch \u0111\u1ec3 chuy\u1ec3n \u0111\u1ed5i t\u1eeb TypeScript sang JavaScript.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"He_thong_go_cua_TypeScript\"><\/span><b>H\u1ec7 th\u1ed1ng g\u00f5 c\u1ee7a TypeScript<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">H\u1ec7 th\u1ed1ng g\u00f5 c\u1ee7a TypeScript \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf cho ph\u00e9p th\u1ec3 hi\u1ec7n c\u00e1c ki\u1ec3u (type) trong TypeScript theo c\u00e1c ki\u1ec3u kh\u00e1c nhau. Generics \u0111\u01b0\u1ee3c xem l\u00e0 ki\u1ec3u c\u01a1 b\u1ea3n c\u1ee7a h\u1ec7 th\u1ed1ng g\u00f5 trong TypeScript. B\u00ean c\u1ea1nh \u0111\u00f3, c\u0169ng c\u00f3 nhi\u1ec1u lo\u1ea1i ki\u1ec3u kh\u00e1c nhau \u0111\u1ec3 s\u1eed d\u1ee5ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">B\u1eb1ng c\u00e1ch k\u1ebft h\u1ee3p nhi\u1ec1u lo\u1ea1i ki\u1ec3u kh\u00e1c nhau, b\u1ea1n c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n c\u00e1c ph\u00e9p to\u00e1n v\u00e0 gi\u00e1 tr\u1ecb ph\u1ee9c t\u1ea1p theo c\u00e1ch ng\u1eafn g\u1ecdn c\u0169ng nh\u01b0 d\u1ec5 b\u1ea3o tr\u00ec h\u01a1n.\u00a0<\/span><\/p>\n<h3><b>Ki\u1ec3u c\u01a1 b\u1ea3n<\/b><\/h3>\n<h4><b>Ch\u00fa th\u00edch c\u01a1 b\u1ea3n (Basic Annotations)<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3u ch\u00fa th\u00edch c\u01a1 b\u1ea3n \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf \u0111\u1ec3 b\u1ea5t k\u1ef3 th\u1ee9 g\u00ec c\u00f3 s\u1eb5n trong kh\u00f4ng gian khai b\u00e1o ki\u1ec3u \u0111\u1ec1u c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 l\u00e0m ch\u00fa th\u00edch. C\u00fa ph\u00e1p c\u1ee7a c\u1ee7a ch\u00fa th\u00edch c\u01a1 b\u1ea3n:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">:TypeAnnotation<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 sau s\u1ebd minh h\u1ecda ki\u1ec3u ch\u00fa th\u00edch cho c\u00e1c bi\u1ebfn, tham s\u1ed1 h\u00e0m v\u00e0 gi\u00e1 tr\u1ecb tr\u1ea3 v\u1ec1 c\u1ee7a h\u00e0m nh\u01b0 sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">var num: number = 123;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">function identity(num: number): number {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0return num;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h4><b>Ki\u1ec3u nguy\u00ean th\u1ee7y (Primitive Types)<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">C\u00e1c ki\u1ec3u nguy\u00ean th\u1ee7y c\u1ee7a JavaScript \u0111\u01b0\u1ee3c th\u1ec3 hi\u1ec7n r\u00f5 trong h\u1ec7 th\u1ed1ng ki\u1ec3u c\u1ee7a TypeScript. Ki\u1ec3u nguy\u00ean th\u1ee7y cung c\u1ea5p c\u00e1c kh\u1ed1i x\u00e2y d\u1ef1ng c\u01a1 b\u1ea3n nh\u01b0 chu\u1ed7i, s\u1ed1, boolean,.. \u0111\u1ea1i di\u1ec7n cho c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u c\u01a1 b\u1ea3n \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong to\u00e0n b\u1ed9 m\u00e3.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">var num: number;<\/span>\r\n<span style=\"font-weight: 400;\">var str: string;<\/span>\r\n<span style=\"font-weight: 400;\">var bool: boolean;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">num = 123;<\/span>\r\n<span style=\"font-weight: 400;\">num = 123.456;<\/span>\r\n<span style=\"font-weight: 400;\">num = '123'; \/\/ L\u1ed7i<\/span>\r\n\r\n<span style=\"font-weight: 400;\">str = '123';<\/span>\r\n<span style=\"font-weight: 400;\">str = 123; \/\/ L\u1ed7i<\/span>\r\n\r\n<span style=\"font-weight: 400;\">bool = true;<\/span>\r\n<span style=\"font-weight: 400;\">bool = false;<\/span>\r\n<span style=\"font-weight: 400;\">bool = 'false'; \/\/ L\u1ed7i<\/span><b><\/b><\/pre>\n<h4><b>M\u1ea3ng (Arrays)<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">TypeScript cung c\u1ea5p c\u00fa ph\u00e1p chuy\u00ean d\u1ee5ng cho m\u1ea3ng \u0111\u1ec3 l\u1eadp tr\u00ecnh vi\u00ean d\u1ec5 d\u00e0ng ch\u00fa th\u00edch v\u00e0 ghi ch\u00fa m\u00e3 c\u1ee7a m\u00ecnh. C\u00fa ph\u00e1p c\u1ee7a m\u1ea3ng s\u1ebd th\u00eam h\u1eadu t\u1ed1 [] v\u00e0o b\u1ea5t k\u1ef3 ch\u00fa th\u00edch ki\u1ec3u h\u1ee3p l\u1ec7 n\u00e0o (v\u00ed d\u1ee5: boolean[]). N\u00f3 s\u1ebd cho ph\u00e9p b\u1ea1n th\u1ef1c hi\u1ec7n c\u00e1c thao t\u00e1c m\u1ea3ng m\u00e0 b\u1ea1n th\u01b0\u1eddng l\u00e0m m\u1ed9t c\u00e1ch an to\u00e0n, h\u1ea1n ch\u1ebf c\u00e1c l\u1ed7i nh\u01b0 g\u00e1n kh\u00f4ng \u0111\u00fang ki\u1ec3u.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">var boolArray: boolean[];<\/span>\r\n\r\n<span style=\"font-weight: 400;\">boolArray = [true, false];<\/span>\r\n<span style=\"font-weight: 400;\">console.log(boolArray[0]); \/\/ true<\/span>\r\n<span style=\"font-weight: 400;\">console.log(boolArray.length); \/\/ 2<\/span>\r\n<span style=\"font-weight: 400;\">boolArray[1] = true;<\/span>\r\n<span style=\"font-weight: 400;\">boolArray = [false, false];<\/span>\r\n\r\n<span style=\"font-weight: 400;\">boolArray[0] = 'false'; \/\/ Error!<\/span>\r\n<span style=\"font-weight: 400;\">boolArray = 'false'; \/\/ Error!<\/span>\r\n<span style=\"font-weight: 400;\">boolArray = [true, 'false']; \/\/ Error!<\/span><b><\/b><\/pre>\n<h4><b>Giao di\u1ec7n (Interfaces)<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Interface l\u00e0 h\u1ec7 th\u1ed1ng g\u00f5 c\u1ed1t l\u00f5i trong TypeScript \u0111\u01b0\u1ee3c d\u00f9ng \u0111\u1ec3 bi\u00ean so\u1ea1n nhi\u1ec1u ki\u1ec3u ch\u00fa th\u00edch th\u00e0nh m\u1ed9t t\u00ean duy nh\u1ea5t. V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">interface Name {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0first: string;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0second: string;<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">var name: Name;<\/span>\r\n<span style=\"font-weight: 400;\">name = {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0first: 'John',<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0second: 'Doe'<\/span>\r\n<span style=\"font-weight: 400;\">};<\/span>\r\n\r\n<span style=\"font-weight: 400;\">name = { \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/L\u1ed7i: `second` kh\u00f4ng x\u00e1c \u0111\u1ecbnh \u0111\u01b0\u1ee3c<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0first: 'John'<\/span>\r\n<span style=\"font-weight: 400;\">};<\/span>\r\n<span style=\"font-weight: 400;\">name = { \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ Error : `second` sai ki\u1ec3u<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0first: 'John',<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0second: 1337<\/span>\r\n<span style=\"font-weight: 400;\">};<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">\u1ede v\u00ed d\u1ee5 tr\u00ean, bi\u00ean so\u1ea1n c\u00e1c ch\u00fa th\u00edch nh\u01b0 string + second:string th\u00e0nh m\u1ed9t ch\u00fa th\u00edch m\u1edbi v\u1edbi Name th\u1ef1c thi ki\u1ec3m tra ki\u1ec3u tr\u00ean t\u1eebng \u0111o\u1ea1n m\u00e3.<\/span><b><\/b><\/p>\n<h4><b>N\u1ed9i tuy\u1ebfn (Inline Type Annotation)<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Thay v\u00ec t\u1ea1o m\u1ed9t giao di\u1ec7n (interface) m\u1edbi, b\u1ea1n c\u00f3 th\u1ec3 ch\u00fa th\u00edch b\u1ea5t k\u1ef3 th\u1ee9 g\u00ec b\u1ea1n mu\u1ed1n b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng :{ \/*Structure*\/ }.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3u n\u1ed9i tuy\u1ebfn nhanh ch\u00f3ng cung c\u1ea5p ch\u00fa th\u00edch ki\u1ec3u m\u1ed9t l\u1ea7n cho m\u1ed9t th\u1ee9 g\u00ec \u0111\u00f3, gi\u00fap b\u1ea1n ti\u1ebft ki\u1ec7m c\u00f4ng s\u1ee9c ngh\u0129 ra t\u00ean ki\u1ec3u. Tuy nhi\u00ean, n\u1ebfu b\u1ea1n th\u1ea5y m\u00ecnh \u0111\u01b0a c\u00f9ng m\u1ed9t ch\u00fa th\u00edch ki\u1ec3u n\u1ed9i tuy\u1ebfn nhi\u1ec1u l\u1ea7n th\u00ec b\u1ea1n n\u00ean c\u00e2n nh\u1eafc vi\u1ec7c t\u00e1i c\u1ea5u tr\u00fac n\u00f3 th\u00e0nh interface.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">var name: {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0first: string;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0second: string;<\/span>\r\n<span style=\"font-weight: 400;\">};<\/span>\r\n<span style=\"font-weight: 400;\">name = {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0first: 'John',<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0second: 'Doe'<\/span>\r\n<span style=\"font-weight: 400;\">};<\/span>\r\n\r\n<span style=\"font-weight: 400;\">name = {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0first: 'John'<\/span>\r\n<span style=\"font-weight: 400;\">};<\/span>\r\n<span style=\"font-weight: 400;\">name = {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0first: 'John',<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0second: 1337<\/span>\r\n<span style=\"font-weight: 400;\">};<\/span><b><\/b><\/pre>\n<h4><b>Generics<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Vi\u1ebft m\u00e3 m\u1ed9t c\u00e1ch linh ho\u1ea1t v\u00e0 c\u00f3 th\u1ec3 ho\u1ea1t \u0111\u1ed9ng v\u1edbi c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u kh\u00e1c nhau b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng generic. \u0110i\u1ec1u n\u00e0y l\u00e0m gi\u1ea3m s\u1ef1 tr\u00f9ng l\u1eb7p m\u00e3 v\u00e0 th\u00fac \u0111\u1ea9y kh\u1ea3 n\u0103ng b\u1ea3o tr\u00ec t\u1ed1t h\u01a1n.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">interface Lengthwise {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0length: number;<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">function loggingIdentity&lt;T extends Lengthwise&gt;(arg: T): T {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0console.log(arg.length);<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0return arg;<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span><b><\/b><\/pre>\n<h3><b>C\u00e1c ki\u1ec3u \u0111\u1eb7c bi\u1ec7t\u00a0<\/b><\/h3>\n<h4><b>any<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">any gi\u1eef m\u1ed9t v\u1ecb tr\u00ed \u0111\u1eb7c bi\u1ec7t trong h\u1ec7 th\u1ed1ng ki\u1ec3u TypeScript, gi\u00fap cung c\u1ea5p m\u1ed9t l\u1ed1i tho\u00e1t kh\u1ecfi h\u1ec7 th\u1ed1ng ki\u1ec3u \u0111\u1ec3 b\u00e1o cho tr\u00ecnh bi\u00ean d\u1ecbch. any t\u01b0\u01a1ng th\u00edch v\u1edbi t\u1ea5t c\u1ea3 c\u00e1c ki\u1ec3u trong h\u1ec7 th\u1ed1ng ki\u1ec3u. \u0110i\u1ec1u n\u00e0y c\u00f3 ngh\u0129a l\u00e0 b\u1ea5t k\u1ef3 ki\u1ec3u n\u00e0o c\u0169ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c g\u00e1n cho any v\u00e0 n\u00f3 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c g\u00e1n cho b\u1ea5t k\u1ef3 ki\u1ec3u n\u00e0o.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">var power: any;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\/\/ C\u00f3 th\u1ec3 l\u1ea5y b\u1ea5t k\u1ef3 ho\u1eb7c t\u1ea5t c\u1ea3 c\u00e1c ki\u1ec3u<\/span>\r\n<span style=\"font-weight: 400;\">power = '123';<\/span>\r\n<span style=\"font-weight: 400;\">power = 123;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\/\/ T\u01b0\u01a1ng th\u00edch v\u1edbi t\u1ea5t c\u1ea3 c\u00e1c ki\u1ec3u<\/span>\r\n<span style=\"font-weight: 400;\">var num: number;<\/span>\r\n<span style=\"font-weight: 400;\">power = num;<\/span>\r\n<span style=\"font-weight: 400;\">num = power;<\/span><b><\/b><\/pre>\n<h4><b>null and undefined<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">null v\u00e0 undefined \u0111\u01b0\u1ee3c x\u1eed l\u00fd b\u1edfi h\u1ec7 th\u1ed1ng ki\u1ec3u ph\u1ee5 thu\u1ed9c v\u00e0o <\/span><span style=\"font-weight: 400;\">strictNullChecks<\/span><span style=\"font-weight: 400;\">. Khi \u1edf trong <\/span><span style=\"font-weight: 400;\">strictNullCheck:false<\/span><span style=\"font-weight: 400;\">, c\u00e1c k\u00fd t\u1ef1 JavaScript null v\u00e0 undefined \u0111\u01b0\u1ee3c x\u1eed l\u00fd hi\u1ec7u qu\u1ea3 b\u1edfi h\u1ec7 th\u1ed1ng ki\u1ec3u gi\u1ed1ng nh\u01b0 any. C\u00e1c k\u00fd t\u1ef1 n\u00e0y c\u0169ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c g\u00e1n cho b\u1ea5t k\u1ef3 ki\u1ec3u n\u00e0o kh\u00e1c.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 nh\u01b0:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">var num: number;<\/span>\r\n<span style=\"font-weight: 400;\">var str: string;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">num = null;<\/span>\r\n<span style=\"font-weight: 400;\">str = undefined;<\/span><b><\/b><\/pre>\n<h4><b>void<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng :void \u0111\u1ec3 bi\u1ec3u th\u1ecb r\u1eb1ng m\u1ed9t h\u00e0m kh\u00f4ng c\u00f3 ki\u1ec3u tr\u1ea3 v\u1ec1:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">function log(message): void {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0console.log(message);<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h3><b>Ki\u1ec3u n\u00e2ng cao<\/b><\/h3>\n<h4><b>Union Type<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Union type l\u00e0 ki\u1ec3u kh\u00e1 ph\u1ed5 bi\u1ebfn trong JavaScript cho ph\u00e9p m\u1ed9t thu\u1ed9c t\u00ednh trong nhi\u1ec1u ki\u1ec3u, v\u00ed d\u1ee5 nh\u01b0 chu\u1ed7i (string) ho\u1eb7c s\u1ed1 (number). M\u1ed9t tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng union type ph\u1ed5 bi\u1ebfn l\u00e0 m\u1ed9t h\u00e0m c\u00f3 th\u1ec3 l\u1ea5y m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng duy nh\u1ea5t ho\u1eb7c m\u1ed9t m\u1ea3ng c\u1ee7a \u0111\u1ed1i t\u01b0\u1ee3ng, v\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">function formatCommandline(command: string[]|string) {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0if (typeof command === 'string') {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return command.trim();<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0} else if (Array.isArray(command)) {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return command.join(' ').trim();<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0}<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0throw new Error('Invalid command type');<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h4><b>Intersection Type\u00a0<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">extend l\u00e0 m\u1ed9t ki\u1ec3u ph\u1ed5 bi\u1ebfn trong JavaScript, trong \u0111\u00f3 l\u1ea5y hai \u0111\u1ed1i t\u01b0\u1ee3ng v\u00e0 t\u1ea1o m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng m\u1edbi c\u00f3 \u0111\u1ea7y \u0111\u1ee7 t\u00ednh n\u0103ng c\u1ee7a c\u1ea3 hai \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0y. Intersection Type cho ph\u00e9p b\u1ea1n s\u1eed d\u1ee5ng m\u1eabu n\u00e0y theo c\u00e1ch an to\u00e0n h\u01a1n, v\u00ed d\u1ee5 nh\u01b0:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">function extend&lt;T, U&gt;(first: T, second: U): T &amp; U {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0return { ...first, ...second };<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">const x = extend({ a: \"hello\" }, { b: 42 });<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\/\/ x c\u00f3 c\u1ea3 gi\u00e1 tr\u1ecb `a` v\u00e0 `b`<\/span>\r\n<span style=\"font-weight: 400;\">const a = x.a;<\/span>\r\n<span style=\"font-weight: 400;\">const b = x.b;<\/span><b><\/b><\/pre>\n<h4><b>Tuple Type\u00a0<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">JavaScript kh\u00f4ng c\u00f3 h\u1ed7 tr\u1ee3 tuple type, l\u1eadp tr\u00ecnh vi\u00ean th\u01b0\u1eddng ch\u1ec9 s\u1eed d\u1ee5ng m\u1ed9t m\u1ea3ng nh\u01b0 m\u1ed9t tuple. Tuple c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c ch\u00fa th\u00edch b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng [typeofmember1, typeofmember2]. M\u1ed9t tuple c\u00f3 th\u1ec3 c\u00f3 b\u1ea5t k\u1ef3 s\u1ed1 l\u01b0\u1ee3ng gi\u00e1 tr\u1ecb.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">var nameNumber: [string, number];<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\/\/ Okay<\/span>\r\n<span style=\"font-weight: 400;\">nameNumber = ['Jenny', 8675309];<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\/\/ L\u1ed7i!<\/span>\r\n<span style=\"font-weight: 400;\">nameNumber = ['Jenny', '867-5309'];<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">K\u1ebft h\u1ee3p v\u1edbi s\u1ef1 h\u1ed7 tr\u1ee3 ph\u00e2n h\u00f3a trong TypeScript, c\u00e1c b\u1ed9 d\u1eef li\u1ec7u c\u1ee7a type tuple tr\u00f4ng kh\u00e1 t\u1ed1t nh\u01b0ng th\u1ef1c ch\u1ea5t ch\u00fang l\u00e0 c\u00e1c m\u1ea3ng (array) kh\u00e1c nhau.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">var nameNumber: [string, number];<\/span>\r\n<span style=\"font-weight: 400;\">nameNumber = ['Jenny', 8675309];<\/span>\r\n\r\n<span style=\"font-weight: 400;\">var [name, num] = nameNumber;<\/span><b><\/b><\/pre>\n<h4><b>Type Alis<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3u bi\u1ec7t danh (Type aliases) cho ph\u00e9p t\u1ea1o t\u00ean t\u00f9y ch\u1ec9nh (bi\u1ec7t danh) cho c\u00e1c ki\u1ec3u TypeScript hi\u1ec7n c\u00f3, bao g\u1ed3m c\u00e1c ki\u1ec3u nguy\u00ean th\u1ee7y, ki\u1ec3u h\u1ee3p nh\u1ea5t, ki\u1ec3u giao nhau v\u00e0 th\u1eadm ch\u00ed c\u00e1c ki\u1ec3u ph\u1ee9c t\u1ea1p h\u01a1n nh\u01b0 ki\u1ec3u \u0111\u1ed1i t\u01b0\u1ee3ng v\u00e0 ki\u1ec3u h\u00e0m. Bi\u1ec7t danh ki\u1ec3u \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a b\u1eb1ng t\u1eeb kh\u00f3a ki\u1ec3u theo sau l\u00e0 t\u00ean m\u1edbi, nh\u01b0 \u0111\u01b0\u1ee3c hi\u1ec3n th\u1ecb b\u00ean d\u01b0\u1edbi:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">type Result = \"success\" | \"error\";<\/span>\r\n\r\n<span style=\"font-weight: 400;\">type Point = { x: number; y: number };<\/span>\r\n\r\n<span style=\"font-weight: 400;\">type Greeting = (name: string) =&gt; string;<\/span>\r\n\r\n<span style=\"font-weight: 400;\"> \u00a0const status: Result = \"success\";<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0const origin: Point = { x: 0, y: 0 };<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0const greet: Greeting = (name) =&gt; `Hello, ${name}!`;<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">\u0110o\u1ea1n m\u00e3 tr\u00ean cho th\u1ea5y c\u00e1c tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng kh\u00e1c nhau c\u1ee7a bi\u1ec7t danh cho c\u00e1c ki\u1ec3u kh\u00e1c trong TypeScript v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng ch\u00fang sau khi khai b\u00e1o.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Kh\u00f4ng gi\u1ed1ng nh\u01b0 giao di\u1ec7n (interfaces), b\u1ea1n c\u00f3 th\u1ec3 cung c\u1ea5p m\u1ed9t type alis cho b\u1ea5t k\u1ef3 ch\u00fa th\u00edch ki\u1ec3u n\u00e0o, mi\u1ec5n l\u00e0 ch\u00fang h\u1eefu \u00edch cho nh\u1eefng th\u1ee9 nh\u01b0 union type ho\u1eb7c intersection type. V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">type Text = string | { text: string };<\/span>\r\n\r\n<span style=\"font-weight: 400;\">type Coordinates = [number, number];<\/span>\r\n\r\n<span style=\"font-weight: 400;\">type Callback = (data: string) =&gt; void;<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Lap_trinh_huong_doi_tuong_Object-Oriented_Programming_%E2%80%93_OOP_trong_TypeScript\"><\/span><b>L\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng (Object-Oriented Programming &#8211; OOP) trong TypeScript\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">OOP (Object-Oriented Programming) l\u00e0 m\u1ed9t m\u00f4 h\u00ecnh d\u1ef1a tr\u00ean kh\u00e1i ni\u1ec7m \u201c\u0111\u1ed1i t\u01b0\u1ee3ng\u201d (object) t\u01b0\u01a1ng t\u00e1c \u0111\u1ec3 t\u1ea1o ra m\u00e3 c\u00f3 th\u1ec3 b\u1ea3o tr\u00ec v\u00e0 t\u00e1i s\u1eed d\u1ee5ng.\u00a0<\/span><\/p>\n<h3><b>TypeScript classes<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">C\u00e1c l\u1edbp (classes) l\u00e0 c\u00e1c m\u1eabu ho\u1eb7c b\u1ea3n thi\u1ebft k\u1ebf \u0111\u1ec3 t\u1ea1o c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng, t\u1ee9c l\u00e0 ch\u00fang \u0111\u1ecbnh ngh\u0129a d\u1eef li\u1ec7u (thu\u1ed9c t\u00ednh) v\u00e0 ph\u01b0\u01a1ng th\u1ee9c (h\u00e0m).<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00e1c Access Modifiers trong TypeScript:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>public:<\/b><span style=\"font-weight: 400;\"> Truy c\u1eadp t\u1eeb b\u1ea5t k\u1ef3 \u0111\u00e2u (m\u1eb7c \u0111\u1ecbnh)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>private:<\/b><span style=\"font-weight: 400;\"> Ch\u1ec9 truy c\u1eadp trong class<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>protected:<\/b><span style=\"font-weight: 400;\"> Truy c\u1eadp trong class v\u00e0 class k\u1ebf th\u1eeba<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">class Organization {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0private name: string;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0private yearFounded: number;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0constructor(name: string, yearFounded: number) {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.name = name;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.yearFounded = yearFounded;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0}<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0public getDetails(): string {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return `${this.name} was founded in ${this.yearFounded}.`;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0}<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0}<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0let organization = new Organization(\"ITviec\", 2015);<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0console.log(organization.name); \/\/ L\u1ed7i: Thu\u1ed9c t\u00ednh 'name' l\u00e0 ri\u00eang t\u01b0 v\u00e0 ch\u1ec9 c\u00f3 th\u1ec3 truy c\u1eadp \u0111\u01b0\u1ee3c trong l\u1edbp 'Organization'.<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0console.log(organization.getDetails()); \/\/ Output: ITviec \u0111\u01b0\u1ee3c th\u00e0nh l\u1eadp n\u0103m 2015.<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Qua v\u00ed d\u1ee5 tr\u00ean, t\u1ea1o m\u1ed9t l\u1edbp Organization v\u1edbi c\u00e1c thu\u1ed9c t\u00ednh ri\u00eang l\u00e0 name v\u00e0 yearFounded, ch\u1ec9 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c truy c\u1eadp v\u00e0 s\u1eeda \u0111\u1ed5i trong l\u1edbp \u201cOrganization\u201d.\u00a0<\/span><\/p>\n<h4><span style=\"font-weight: 400;\"><strong>Inheritance (K\u1ebf th\u1eeba)<\/strong><\/span><\/h4>\n<pre><span style=\"font-weight: 400;\">class Animal {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0protected name: string;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0constructor(name: string) {\u00a0<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0this.name = name;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0}<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">class Dog extends Animal {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0bark() {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return `${this.name} barks`;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0}<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h4><span style=\"font-weight: 400;\"><strong>Abstract Classes<\/strong><\/span><\/h4>\n<pre><span style=\"font-weight: 400;\">abstract class Base {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0abstract getName(): string;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0printName() {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0console.log(this.getName());<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0}<\/span>\r\n<span style=\"font-weight: 400;\">}<\/span><b><\/b><\/pre>\n<h3><b>TypeScript Interface<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Giao di\u1ec7n (interface) m\u00f4 t\u1ea3 h\u00ecnh d\u1ea1ng c\u1ee7a c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng b\u1eb1ng c\u00e1ch li\u1ec7t k\u00ea c\u00e1c thu\u1ed9c t\u00ednh v\u00e0 ph\u01b0\u01a1ng th\u1ee9c m\u00e0 ch\u00fang c\u1ea7n, m\u00e0 kh\u00f4ng cung c\u1ea5p b\u1ea5t k\u1ef3 chi ti\u1ebft tri\u1ec3n khai n\u00e0o.\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">interface FormData {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0firstName: string;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0lastName: string;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0email: string;<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0age: number;<\/span>\r\n<span style=\"font-weight: 400;\"> }<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0<\/span>\r\n<span style=\"font-weight: 400;\">let formData: FormData = {<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0firstName: \"John\",<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0lastName: \"Doe\",<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0email: \"john.doe@example.com\",<\/span>\r\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0age: 30<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0};<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">\u1ede v\u00ed d\u1ee5 tr\u00ean, \u0111\u1ecbnh ngh\u0129a m\u1ed9t giao di\u1ec7n FormData bi\u1ec3u di\u1ec5n c\u1ea5u tr\u00fac c\u1ee7a d\u1eef li\u1ec7u m\u1eabu. Sau \u0111\u00f3 t\u1ea1o ra m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng formData v\u1edbi c\u00e1c thu\u1ed9c t\u00ednh t\u01b0\u01a1ng \u1ee9ng v\u1edbi \u0111\u1ecbnh ngh\u0129a giao di\u1ec7n.\u00a0<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Moi_quan_he_giua_TypeScript_vs_JavaScript\"><\/span><b>M\u1ed1i quan h\u1ec7 gi\u1eefa TypeScript vs JavaScript\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>Bi\u00ean d\u1ecbch sang JavaScript<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Tr\u00ecnh duy\u1ec7t ch\u1ec9 hi\u1ec3u v\u00e0 th\u1ef1c thi m\u00e3 JavaScript, do \u0111\u00f3 \u0111\u1ec3 ch\u1ea1y \u0111\u01b0\u1ee3c m\u00e3 TypeScript th\u00ec tr\u01b0\u1edbc ti\u00ean m\u00e3 ph\u1ea3i \u0111\u01b0\u1ee3c bi\u00ean d\u1ecbch ho\u1eb7c chuy\u1ec3n \u0111\u1ed5i th\u00e0nh JavaScript. Qu\u00e1 tr\u00ecnh bi\u00ean d\u1ecbch s\u1ebd s\u1eed d\u1ee5ng TypeScript tsc, \u0111\u00e2y l\u00e0 tr\u00ecnh bi\u00ean d\u1ecbch s\u1ebd chuy\u1ec3n \u0111\u1ed5i m\u1ecdi t\u00ednh n\u0103ng ri\u00eang cho TypeScript th\u00e0nh m\u00e3 t\u01b0\u01a1ng th\u00edch v\u1edbi c\u00f4ng c\u1ee5 JavaScript.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Qu\u00e1 tr\u00ecnh bi\u00ean d\u1ecbch s\u1ebd \u0111\u01b0\u1ee3c b\u1eaft \u0111\u1ea7u b\u1eb1ng ph\u00e2n t\u00edch c\u00fa ph\u00e1p r\u1ed3i sau \u0111\u00f3 ti\u1ebfn h\u00e0nh d\u1ecbch m\u00e3, c\u1ee5 th\u1ec3:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ph\u00e2n t\u00edch c\u00fa ph\u00e1p:<\/b><span style=\"font-weight: 400;\"> Tr\u00ecnh bi\u00ean d\u1ecbch s\u1ebd \u0111\u1ecdc m\u00e3 TypeScript v\u00e0 ph\u00e2n t\u00edch ho\u1eb7c chuy\u1ec3n m\u00e3 th\u00e0nh c\u1ea5u tr\u00fac d\u1eef li\u1ec7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ki\u1ec3m tra ki\u1ec3u:<\/b><span style=\"font-weight: 400;\"> Tr\u00ecnh bi\u00ean d\u1ecbch c\u0169ng s\u1ebd th\u1ef1c hi\u1ec7n ki\u1ec3m tra ki\u1ec3u d\u1ef1a tr\u00ean ch\u00fa th\u00edch (annotations) v\u00e0 ph\u00e2n t\u00edch \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o m\u00e3 tu\u00e2n th\u1ee7 c\u00e1c ki\u1ec3u \u0111\u00e3 x\u00e1c \u0111\u1ecbnh.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Chuy\u1ec3n \u0111\u1ed5i: <\/b><span style=\"font-weight: 400;\">Th\u1ef1c hi\u1ec7n chuy\u1ec3n \u0111\u1ed5i m\u00e3 d\u1ef1a tr\u00ean AST v\u00e0 k\u1ebft qu\u1ea3 ki\u1ec3m tra ki\u1ec3u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>T\u1ea1o m\u00e3: <\/b><span style=\"font-weight: 400;\">T\u1ea1o m\u00e3 JavaScript t\u01b0\u01a1ng \u0111\u01b0\u01a1ng d\u1ef1a tr\u00ean c\u1ea5u tr\u00fac AST \u0111\u00e3 chuy\u1ec3n \u0111\u1ed5i v\u00e0 gi\u1eef nguy\u00ean ch\u1ee9c n\u0103ng c\u1ee7a m\u00e3 TypeScript.<\/span><\/li>\n<\/ul>\n<h3><b>Kh\u1ea3 n\u0103ng t\u01b0\u01a1ng th\u00edch v\u1edbi JavaScript<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p c\u1ee7a JavaScript v\u00e0 TypeScript c\u00f3 th\u1ec3 c\u00f9ng s\u1eed d\u1ee5ng trong m\u1ed9t d\u1ef1 \u00e1n. Tuy nhi\u00ean, \u0111\u1ec3 s\u1eed d\u1ee5ng kh\u1ea3 n\u0103ng c\u1ee7a TypeScript c\u1ea7n c\u00f3 tr\u00ecnh bi\u00ean d\u1ecbch m\u00e3 sang JavaScript.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Kh\u1ea3 n\u0103ng t\u01b0\u01a1ng th\u00edch gi\u1eefa 2 ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh n\u00e0y c\u00f3 th\u1ec3 \u0111em l\u1ea1i m\u1ed9t s\u1ed1 l\u1ee3i th\u1ebf nh\u01b0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u01a1 s\u1edf m\u00e3 JavaScript c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c di chuy\u1ec3n d\u1ea7n sang TypeScript, y\u00eau c\u1ea7u tr\u00ecnh bi\u00ean d\u1ecbch TypeScript v\u00e0 t\u1ec7p tsconfig ch\u1ec9 \u0111\u1ecbnh c\u00e1c t\u00f9y ch\u1ecdn tr\u00ecnh bi\u00ean d\u1ecbch.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">TypeScript cung c\u1ea5p h\u1ec7 th\u1ed1ng ki\u1ec3u cho ph\u00e9p l\u1eadp tr\u00ecnh vi\u00ean ch\u1ec9 \u0111\u1ecbnh ki\u1ec3u bi\u1ebfn.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">M\u00e3 TypeScript \u0111\u01b0\u1ee3c bi\u00ean d\u1ecbch sang JavaScript tr\u01b0\u1edbc khi th\u1ef1c thi n\u00ean s\u1ebd t\u01b0\u01a1ng th\u00edch v\u1edbi b\u1ea5t k\u1ef3 m\u00f4i tr\u01b0\u1eddng th\u1eddi gian ch\u1ea1y c\u1ee7a JavaScript.<\/span><\/li>\n<\/ul>\n<h3><strong>So s\u00e1nh TypeScript vs JavaScript<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\">B\u00ean c\u1ea1nh \u0111\u00f3, gi\u1eefa TypeScript vs JavaScript c\u00f2n c\u00f3 s\u1ef1 kh\u00e1c bi\u1ec7t qua m\u1ed9t s\u1ed1 ti\u00eau ch\u00ed nh\u01b0 sau:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Ti\u00eau ch\u00ed<\/b><\/td>\n<td><b>TypeScript<\/b><\/td>\n<td><b>JavaScript<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Ph\u00e1t tri\u1ec3n b\u1edfi<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Microsoft<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Brendan Eich (Netscape), hi\u1ec7n \u0111\u01b0\u1ee3c qu\u1ea3n l\u00fd b\u1edfi ECMAScript committee<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Ki\u1ec3u<\/span><\/td>\n<td><span style=\"font-weight: 400;\"> Static typing v\u1edbi optional type annotations<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Dynamic typing v\u00e0 weak typing<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">C\u00f4ng c\u1ee5<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u0110i k\u00e8m IDE v\u00e0 tr\u00ecnh so\u1ea1n th\u1ea3o m\u00e3<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Nhi\u1ec1u c\u00f4ng c\u1ee5 ph\u00e1t tri\u1ec3n m\u1ea1nh m\u1ebd (DevTools, debugging tools, linters)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Data Binding<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng interface ho\u1eb7c type \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh d\u1eef li\u1ec7u<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Kh\u00f4ng c\u00f3 kh\u00e1i ni\u1ec7m n\u00e0o \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p<\/span><\/td>\n<td><span style=\"font-weight: 400;\">T\u01b0\u01a1ng t\u1ef1 JavaScript v\u00e0 c\u00f3 b\u1ed5 sung c\u00e1c t\u00ednh n\u0103ng m\u1edbi<\/span><\/td>\n<td><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p JavaScript<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">IDE Support<\/span><\/td>\n<td><span style=\"font-weight: 400;\">H\u1ed7 tr\u1ee3 t\u00e1i c\u1ea5u tr\u00fac, t\u1ef1 \u0111\u1ed9ng ho\u00e0n th\u00e0nh v\u00e0 ki\u1ec3m tra type.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">IDE kh\u00e1c nhau, t\u1eadp trung v\u00e0o highlight v\u00e0 t\u1ef1 \u0111\u1ed9ng ho\u00e0n th\u00e0nh c\u00fa ph\u00e1p c\u01a1 b\u1ea3n<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Debug<\/span><\/td>\n<td><span style=\"font-weight: 400;\">M\u1ea1nh h\u01a1n<\/span><\/td>\n<td><span style=\"font-weight: 400;\">C\u1ea7n g\u1ee1 l\u1ed7i v\u00e0 th\u1eed nghi\u1ec7m nhi\u1ec1u h\u01a1n<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">\u1ee8ng d\u1ee5ng<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u1ee8ng d\u1ee5ng cho c\u00e1c d\u1ef1 \u00e1n quy m\u00f4 l\u1edbn, d\u1ef1 \u00e1n theo nh\u00f3m ho\u1eb7c d\u1ef1 \u00e1n l\u00e2u d\u00e0i<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u0110a d\u1ea1ng \u1ee9ng d\u1ee5ng, \u0111\u1eb7c bi\u1ec7t l\u00e0 c\u00e1c d\u1ef1 \u00e1n nh\u1ecf<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400;\">Learning Curve<\/span><\/td>\n<td><span style=\"font-weight: 400;\">C\u1ea7n c\u00f3 ki\u1ebfn th\u1ee9c v\u1ec1 script v\u00e0 t\u00ecm hi\u1ec3u th\u00eam t\u00ednh n\u0103ng b\u1ed5 sung c\u1ee7a JavaScript<\/span><\/td>\n<td><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p JavaScript d\u1ec5 h\u1ecdc, v\u00e0 ng\u00f4n ng\u1eef linh ho\u1ea1t \u0111\u1ec3 vi\u1ebft t\u1eadp l\u1ec7nh website<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote><p><i>Xem th\u00eam: <\/i><strong><a href=\"https:\/\/itviec.com\/blog\/typescript-vs-javascript\/\" target=\"_blank\" rel=\"noopener\"><i>TypeScript vs JavaScript: T\u00ednh n\u0103ng v\u00e0 tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng<\/i><\/a><\/strong><\/p><\/blockquote>\n<h2><span class=\"ez-toc-section\" id=\"Cau_hoi_thuong_gap_ve_TypeScript_la_gi\"><\/span><b>C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 TypeScript l\u00e0 g\u00ec<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>H\u1ecdc TypeScript m\u1ea5t bao l\u00e2u?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Th\u1eddi gian h\u1ecdc TypeScript s\u1ebd ph\u1ee5 thu\u1ed9c v\u00e0o kinh nghi\u1ec7m c\u0169ng nh\u01b0 th\u1eddi gian b\u1ea1n c\u00f3 th\u1ec3 d\u00e0nh ra cho vi\u1ec7c h\u1ecdc. N\u1ebfu b\u1ea1n l\u00e0 ng\u01b0\u1eddi m\u1edbi b\u1eaft \u0111\u1ea7u th\u00ec b\u1ea1n s\u1ebd c\u1ea7n h\u1ecdc tr\u01b0\u1edbc v\u1ec1 JavaScript, qu\u00e1 tr\u00ecnh c\u00f3 th\u1ec3 m\u1ea5t v\u00e0i tu\u1ea7n \u0111\u1ebfn v\u00e0i th\u00e1ng. Ho\u1eb7c n\u1ebfu b\u1ea1n \u0111\u00e3 c\u00f3 n\u1ec1n t\u1ea3ng ki\u1ebfn th\u1ee9c v\u1ec1 JavaScript th\u00ec th\u1eddi gian h\u1ecdc v\u00e0 l\u00e0m quen v\u1edbi TypeScript c\u00f3 th\u1ec3 r\u00fat ng\u1eafn h\u01a1n, trung b\u00ecnh 2-4 tu\u1ea7n.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 vi\u1ec7c h\u1ecdc \u0111\u1ea1t hi\u1ec7u qu\u1ea3, b\u1ea1n c\u1ea7n x\u00e1c \u0111\u1ecbnh v\u00e0 l\u1eadp cho m\u00ecnh m\u1ed9t <\/span><strong><a href=\"https:\/\/itviec.com\/blog\/lo-trinh-hoc-typescript\/\" target=\"_blank\" rel=\"noopener\">l\u1ed9 tr\u00ecnh h\u1ecdc TypeScript<\/a><\/strong><span style=\"font-weight: 400;\"> ph\u00f9 h\u1ee3p. T\u1eeb \u0111\u00f3 b\u1ea1n s\u1ebd c\u00f3 g\u00f3c nh\u00ecn r\u00f5 h\u01a1n v\u1ec1 th\u1eddi gian h\u1ecdc c\u0169ng nh\u01b0 c\u00e1c k\u1ef9 n\u0103ng m\u00e0 b\u1ea3n th\u00e2n s\u1ebd \u0111\u1ea1t \u0111\u01b0\u1ee3c sau khi h\u1ecdc TypeScript.\u00a0<\/span><\/p>\n<h3><b>S\u1eed d\u1ee5ng TypeScript v\u1edbi React \u0111\u01b0\u1ee3c kh\u00f4ng?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Vi\u1ec7c s\u1eed d\u1ee5ng React \u0111\u1ec3 ph\u00e1t tri\u1ec3n web l\u00e0 m\u1ed9t l\u1ef1a ch\u1ecdn ph\u00f9 h\u1ee3p \u0111\u1ec3 x\u00e2y d\u1ef1ng s\u1ef1 tr\u1ef1c quan v\u00e0 ph\u1ea3n h\u1ed3i tr\u00ean web v\u1edbi giao di\u1ec7n ng\u01b0\u1eddi d\u00f9ng. K\u1ebft h\u1ee3p React v\u1edbi TypeScript c\u00f3 th\u1ec3 \u0111em l\u1ea1i m\u1ed9t s\u1ed1 l\u1ee3i \u00edch nh\u01b0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">D\u1ec5 d\u00e0ng ph\u00e1t hi\u1ec7n l\u1ed7i, l\u00e0m vi\u1ec7c v\u1edbi ki\u1ec3u t\u0129nh v\u00e0 b\u1ea3o tr\u00ec m\u00e3 d\u1ec5 d\u00e0ng h\u01a1n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u0110i k\u00e8m v\u1edbi h\u1ed7 tr\u1ee3 v\u00e0 c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd, c\u00f3 th\u1ec3 qu\u1ea3n l\u00fd \u0111i\u1ec1u h\u01b0\u1edbng m\u00e3, t\u1eeb \u0111\u00f3 c\u1ea3i thi\u1ec7n hi\u1ec7u su\u1ea5t d\u1ec5 d\u00e0ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u1ea3i thi\u1ec7n giao di\u1ec7n ng\u01b0\u1eddi d\u00f9ng nhanh v\u00e0 hi\u1ec7u qu\u1ea3 h\u01a1n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ph\u00e1t hi\u1ec7n l\u1ed7i compile-time.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Type safety cho hooks v\u00e0 components.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Tong_ket_TypeScript_la_gi\"><\/span><b>T\u1ed5ng k\u1ebft TypeScript l\u00e0 g\u00ec<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">\u0110\u01b0\u1ee3c bi\u1ebft \u0111\u1ebfn l\u00e0 ng\u00f4n ng\u1eef m\u1edf r\u1ed9ng c\u1ee7a JavaScript c\u00f9ng c\u01a1 ch\u1ebf ki\u1ec3u t\u0129nh, TypeScript gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean vi\u1ebft m\u00e3 an to\u00e0n, d\u1ec5 b\u1ea3o tr\u00ec v\u00e0 t\u1ed1i \u01b0u hi\u1ec7u su\u1ea5t. V\u1edbi nh\u1eefng l\u1ee3i \u00edch v\u01b0\u1ee3t tr\u1ed9i so v\u1edbi JavaScript, TypeScript \u0111ang tr\u1edf th\u00e0nh xu h\u01b0\u1edbng ph\u1ed5 bi\u1ebfn trong ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m. Nh\u01b0 v\u1eady, b\u00e0i vi\u1ebft \u0111\u00e3 gi\u1ea3i \u0111\u00e1p chi ti\u1ebft v\u1ec1 TypeScript l\u00e0 g\u00ec c\u0169ng nh\u01b0 nh\u1eefng l\u1ee3i \u00edch v\u01b0\u1ee3t tr\u1ed9i c\u1ee7a TypeScript.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>TypeScript l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh m\u1edf r\u1ed9ng c\u1ee7a JavaScript, gi\u00fap m\u00e3 ngu\u1ed3n d\u1ec5 \u0111\u1ecdc v\u00e0 h\u1ea1n ch\u1ebf l\u1ed7i nh\u1edd c\u01a1 ch\u1ebf ki\u1ec3m tra ki\u1ec3u t\u0129nh. L\u00e0 ng\u00f4n ng\u1eef \u0111\u01b0\u1ee3c ph\u00e1t tri\u1ec3n b\u1edfi Microsoft, TypeScript ng\u00e0y c\u00e0ng ph\u1ed5 bi\u1ebfn trong vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng web hi\u1ec7n \u0111\u1ea1i. V\u1eady TypeScript l\u00e0 g\u00ec v\u00e0 [&hellip;]<\/p>\n","protected":false},"author":207,"featured_media":84631,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109],"tags":[],"class_list":["post-84507","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>TypeScript l\u00e0 g\u00ec: T\u00ecm hi\u1ec3u chi ti\u1ebft v\u1ec1 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a TypeScript - ITviec Blog<\/title>\n<meta name=\"description\" content=\"hi\u1ec3u TypeScript l\u00e0 g\u00ec, m\u1ed9t ng\u00f4n ng\u1eef m\u1edf r\u1ed9ng c\u1ee7a JavaScript v\u1edbi chi ti\u1ebft h\u1ec7 th\u1ed1ng g\u00f5, c\u00e1ch s\u1eed d\u1ee5ng v\u00e0 t\u1ea1i sao n\u00ean s\u1eed d\u1ee5ng TypeScript.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TypeScript l\u00e0 g\u00ec: T\u00ecm hi\u1ec3u chi ti\u1ebft v\u1ec1 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a TypeScript\" \/>\n<meta property=\"og:description\" content=\"TypeScript l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh m\u1edf r\u1ed9ng c\u1ee7a JavaScript, gi\u00fap m\u00e3 ngu\u1ed3n d\u1ec5 \u0111\u1ecdc v\u00e0 h\u1ea1n ch\u1ebf l\u1ed7i nh\u1edd c\u01a1 ch\u1ebf ki\u1ec3m tra ki\u1ec3u t\u0129nh. L\u00e0 ng\u00f4n ng\u1eef \u0111\u01b0\u1ee3c ph\u00e1t\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/typescript-la-gi\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-26T01:58:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/02\/typescript-la-gi-vippro.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1500\" \/>\n\t<meta property=\"og:image:height\" content=\"790\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Uyen Ngo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"Uyen Ngo\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"TypeScript l\u00e0 g\u00ec: T\u00ecm hi\u1ec3u chi ti\u1ebft v\u1ec1 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a TypeScript - ITviec Blog","description":"hi\u1ec3u TypeScript l\u00e0 g\u00ec, m\u1ed9t ng\u00f4n ng\u1eef m\u1edf r\u1ed9ng c\u1ee7a JavaScript v\u1edbi chi ti\u1ebft h\u1ec7 th\u1ed1ng g\u00f5, c\u00e1ch s\u1eed d\u1ee5ng v\u00e0 t\u1ea1i sao n\u00ean s\u1eed d\u1ee5ng TypeScript.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itviec.com\/blog\/typescript-la-gi\/","og_locale":"vi_VN","og_type":"article","og_title":"TypeScript l\u00e0 g\u00ec: T\u00ecm hi\u1ec3u chi ti\u1ebft v\u1ec1 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a TypeScript","og_description":"TypeScript l\u00e0 m\u1ed9t ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh m\u1edf r\u1ed9ng c\u1ee7a JavaScript, gi\u00fap m\u00e3 ngu\u1ed3n d\u1ec5 \u0111\u1ecdc v\u00e0 h\u1ea1n ch\u1ebf l\u1ed7i nh\u1edd c\u01a1 ch\u1ebf ki\u1ec3m tra ki\u1ec3u t\u0129nh. L\u00e0 ng\u00f4n ng\u1eef \u0111\u01b0\u1ee3c ph\u00e1t","og_url":"https:\/\/itviec.com\/blog\/typescript-la-gi\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-02-26T01:58:27+00:00","og_image":[{"width":1500,"height":790,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/02\/typescript-la-gi-vippro.jpeg","type":"image\/jpeg"}],"author":"Uyen Ngo","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Uyen Ngo","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"17 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/"},"author":{"name":"Uyen Ngo","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/f4cd1226846e0258c664e170d3e52d20"},"headline":"TypeScript l\u00e0 g\u00ec: T\u00ecm hi\u1ec3u chi ti\u1ebft v\u1ec1 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a TypeScript","datePublished":"2025-02-26T01:58:27+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/"},"wordCount":4398,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/02\/typescript-la-gi-vippro.jpeg","articleSection":["Chuy\u00ean m\u00f4n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/","url":"https:\/\/itviec.com\/blog\/typescript-la-gi\/","name":"TypeScript l\u00e0 g\u00ec: T\u00ecm hi\u1ec3u chi ti\u1ebft v\u1ec1 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a TypeScript - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/02\/typescript-la-gi-vippro.jpeg","datePublished":"2025-02-26T01:58:27+00:00","description":"hi\u1ec3u TypeScript l\u00e0 g\u00ec, m\u1ed9t ng\u00f4n ng\u1eef m\u1edf r\u1ed9ng c\u1ee7a JavaScript v\u1edbi chi ti\u1ebft h\u1ec7 th\u1ed1ng g\u00f5, c\u00e1ch s\u1eed d\u1ee5ng v\u00e0 t\u1ea1i sao n\u00ean s\u1eed d\u1ee5ng TypeScript.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/typescript-la-gi\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/02\/typescript-la-gi-vippro.jpeg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/02\/typescript-la-gi-vippro.jpeg","width":1500,"height":790,"caption":"typescript l\u00e0 g\u00ec - itviec blog"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/typescript-la-gi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Chuy\u00ean m\u00f4n IT","item":"https:\/\/itviec.com\/blog\/chuyen-mon-it\/"},{"@type":"ListItem","position":2,"name":"TypeScript l\u00e0 g\u00ec: T\u00ecm hi\u1ec3u chi ti\u1ebft v\u1ec1 c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a TypeScript"}]},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/f4cd1226846e0258c664e170d3e52d20","name":"Uyen Ngo","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/ngo-thieu-my-uyen-author-e1709880420317-100x100.jpg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/ngo-thieu-my-uyen-author-e1709880420317-100x100.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/ngo-thieu-my-uyen-author-e1709880420317-100x100.jpg","caption":"Uyen Ngo"},"url":"https:\/\/itviec.com\/blog\/author\/uyen-ngo\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/84507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/207"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=84507"}],"version-history":[{"count":0,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/84507\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/84631"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=84507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=84507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=84507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}