起步

PPG007 ... 2023-4-28 Less than 1 minute

# 起步

# 安装 TypeScript

mkdir playground
cd playground
# please install yarn before next command
yarn init
yarn add typescript
1
2
3
4
5

# Hello World

main.ts:

function helloWorld(name: string) {
    console.log(`I am ${name}, hello TypeScript!`);
}

const me = 'PPG007';
helloWorld(me);
1
2
3
4
5
6

然后执行 tsc main.ts,此时会得到一个 main.js 文件,这个文件就是执行编译的结果,执行这个 js 文件即可。

Last update: April 28, 2023 09:33
Contributors: Koston Zhuang