iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 1
2
Modern Web

TypeScript - 初學之路系列 第 1

Day01 - Install TypeScript

緣起

寫了 Javascript 一段時間

NodejsJavascript 前後端之亂

出現了 browserify 來統一了前後端

近幾年的 ES5ES6ES7 大亂鬥

也需要由 babel 來緩和三個世代的戰鬥

但是快速發展的同時

版本之亂也是一個很大的問題

之前就有聽說過 TypeScript

直到近幾個月才有空開始玩了一下

也有它存在的優勢

所以就開始跳下來學習

趁著這三十天整理一下心得

第一天當然就是要安裝啊

有兩個主要的安裝方式

  • 使用 NPM 安裝
  • 安裝 [Visual Studio plugins]

Visual Studio

Visual Studio 2017 和 Visual Studio 2015 預設已經有使用 TypeScript ,但若是你不希望安裝 Visual Studio 你也可以安裝 TypeScript

NPM

  $ npm install -g typescript

Hello world

helloword.ts

const message: string = 'Hello World!';

寫完之後要經過編譯才能執行

    $ tsc helloworld.ts

同一個資料夾中會多一個 helloworld.js

    $ node helloworld.js // Hello world

哈囉 世界

哈囉 TypeScript


下一篇
Day02 - 變數
系列文
TypeScript - 初學之路8
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言