首页 > IT职业 > IT图书 > typescript 笔记 01
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/ ,如需转载,请注明出处,否则将追究法律责任。