typescript 学习笔记系列--第一个ts代码

1.hello.ts

function greeter(person) {
  return 'Hello, ' + person
}

let user = 'Yee'

console.log(greeter(user))

2.手动编译

tsc ./hello.ts

3.在html文件中引入编译后的 hello.js

<!DOCTYPE html>
<html><body>
<script src="hello.js"></script>
</body></html>


版权声明:本文为taotaobaobei原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。