iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 1
0
自我挑戰組

霍普菜鳥的資訊工作雜記系列 第 11

D11-typescript step by step

  • 分享至 

  • xImage
  •  

evn of vs code

config task.json for batch jobs (compile ts to js)

{
    "taskName": "test build",
    "command": "tsc --out ./js/test.js ./ts/test.ts",
    "type": "shell",
    "group": {
        "kind": "build",
        "isDefault": true
    },
    "problemMatcher": [
        "$lessCompile"
    ]
}

config launch.json for debug

{
    "type": "node",
    "request": "launch",
    "name": "Launch Program",
    "preLaunchTask":"test build", //the task  name in task.json
    "program": "${workspaceRoot}/js/test.js",
    "outFiles": [
        "${workspaceRoot}/out/**/*.js"
    ]
}

initial project

~~~
	mkdir projectname
	cd projectname
	npm init // or cordova create for cordova project!!
	tsc --init
	npm install --save @types/lodash  // for ts type definition 
	
	npm install --save packagename 		  //install package
	npm install --save-dev @types/packagename //install type define of the package
	
	vi tsconfig.json
	update typeRoots, add the path ["./node_modules/@types"]
~~~

reference

https://hackmd.io/s/rkITEOYX
https://github.com/kkbruce/TypeScript/blob/master/doc/zh-tw/Handbook.md
https://zhongsp.gitbooks.io/typescript-handbook/content/doc/handbook/Basic%20Types.html


上一篇
D10-單頁式頁面切換
下一篇
D12-透過noble藍牙掃描裝置與點燈機制
系列文
霍普菜鳥的資訊工作雜記31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言