ITPub博客

首页 > IT职业 > IT图书 > typescript 笔记 01

typescript 笔记 01

IT图书 作者:zl_king 时间:2021-09-09 08:52:27 0 删除 编辑

环境 && hello world

npm install -g typescript
npm install -g ts-node

初始化工程

npm init -y
npm install -D tslib @types/node

添加一个 ts 文件
main.ts

interface Point {
    x: number
    y: number
}

function sayHelo(data: Point) {
    console.log('hello ts')
    return Math.sqrt(data.x ** 2 + data.y ** 2)
}

sayHelo({x: 2, y: 2})

运行

F:codewebstormts-one>ts-node main.ts
hello ts

F:codewebstormts-one>

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1567/viewspace-2797058/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    102
  • 访问量
    725