创建typescript项目
#cd 一个目录
npm init #初始化
npm install typescript --save-dev
#创建目录结构
projectRoot
├── src
│ ├── file1.js
│ └── file2.js
├── built
└── tsconfig.json
#配置文件tsconfig.json
{
"compilerOptions": {
"outDir": "./built",
"allowJs": true,
"target": "es5"
},
"include": [
"./src/**/*"
]
}
#在src目录下,新建一个index.ts文件,代码如下:
let showMe = (name:string,age:number)=>{
"use strict";
return "我的名字是:"+name+",我的年龄是:"+age;
}
// 调用函数
console.log(showMe("lily",19));
#修改package.json,在scripts段添加:
"scripts": {
"b": "tsc && node ./built/index"
},
#在终端执行
npm run b
$ sudo npm install -g @angular/cli
相关推荐
changcongying 2020-11-02
changcongying 2020-10-30
苗疆三刀的随手记 2020-10-29
zouph000 2020-10-25
Jruing 2020-10-23
ctg 2020-10-14
PMJ0 2020-10-13
ChaITSimpleLove 2020-10-06
小飞侠V 2020-09-25
QiaoranC 2020-09-25
changcongying 2020-09-17
taizuduojie 2020-09-15
淼寒儿 2020-09-13
lyjava 2020-09-11
彤庆的技术 2020-09-02
锅哥 2020-08-27
ruanhongbiao 2020-08-16
zouph000 2020-08-03
Java编程语言学习 2020-07-29