TypeScript
Installing TypeScript
- 透過npm安裝
npm install -g typescript
- 透過TypeScript's Visual Studio plugins 安裝 Visual Studio 2015 and Visual Studio 2013 Update 2 預設包含TypeScript。假如沒有安裝到官網download
建立TypeScript範例
greeter.ts
function greeter(person: string) {
return "Hello, " + person;
}
var user = "Allen";
$("#content").html(greeter(user));
index.html
<!DOCTYPE html>
<html>
<head>
<title>TypeScript Greeter</title>
</head>
<body>
<div id="content"></div>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/TypeScripts/greeter.js"></script>
</body>
</html>