美文网首页
typescript 使用

typescript 使用

作者: 阿啦啦啦啦啦 | 来源:发表于2019-02-14 16:20 被阅读0次

前置条件 hello.ts

let world :string="world"
let hello=`hello ${world}`
console.log(hello)

安装编译工具,进行编译,并用node执行编译后的文件

npm i typescript -g
tsc hello.ts  
node hello.js

会在同级目录下产生hello.js文件

直接执行ts文件

npm i -g ts-node
ts-node hello.ts

这里可能会报错,说typescript 模块没找到,直接在项目中安装下这个模块就好了

npm i typescript -D

相关文章

网友评论

      本文标题:typescript 使用

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