美文网首页
使用 VS Code 搭建 TypeScript 开发环境

使用 VS Code 搭建 TypeScript 开发环境

作者: wh17292 | 来源:发表于2020-07-10 16:46 被阅读0次

使用 VS Code 搭建 TypeScript 开发环境
1.下载 TypeScript

npm install -g typescript

2.创建项目

npm init -yes  //创建一个 package.json
tsc --init  //创建一个 tsconfig.json
创建一个 index.html
创建一个 hello.ts

3.index.html

<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>TypeScript with VSCode</title>
  </head>

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

4.hello.ts

let arr: Array<number> = [1,2,3];
console.log("arr"));

5.先执行npm install -g live-server安装 live-server 之后,修改 package.json

 "scripts": {
    "start": "tsc -w & live-server",
  },

6.执行 npm start 就可以写一些 ts 的小 demo 了

相关文章

网友评论

      本文标题:使用 VS Code 搭建 TypeScript 开发环境

      本文链接:https://www.haomeiwen.com/subject/qbemcktx.html