使用 Visual Studio Code 编写 TypeScript程序

安装 TypeScript

首先,确保你已经安装了 TypeScript,如果没有安装,请参考https://blog.csdn.net/David_house/article/details/134077973?spm=1001.2014.3001.5502进行安装

创建

新建一个文件夹,用vs code打开,在文件夹下新建一个后缀为.ts的文件,加入你的内容

初始化 TypeScript 配置

  1. 点击最上方工具栏的terminal,打开一个新的终端
    terminal->new terminal
  2. 在终端输入命令tsc --init,生成相关的配置文件tsconfig.json

添加任务监听 tsconfig.json

选择terminal->run task,然后选择watch-tsconfig.json

然后项目会自动编译ts 为 js 文件相应目录下

运行

选择生成的js文件,右键run code就可以运行我们的程序了

在output控制台查看打印的结果:

相关推荐
dyxal6 小时前
VS Code 终端疑难杂症排查:为什么 PowerShell 无法启动?
vscode
【ql君】qlexcel6 小时前
Visual Studio Code开发STM32设置头文件宏定义uint32_t报错
vscode·stm32·vs code·头文件宏定义·uint32_t报错·uint8_t报错·uint16_t报错
琉璃榴6 小时前
Visual Studio Code连接远程服务器
服务器·vscode·github
jieyucx8 小时前
Golang 完整安装与 VSCode 开发环境搭建教程
开发语言·vscode·golang
FrontAI9 小时前
深入浅出 LangChain —— 第三章:模型抽象层
前端·人工智能·typescript·langchain·ai agent
凰轮10 小时前
TypeScript 知识点总结
前端·javascript·typescript
|晴 天|11 小时前
Element Plus 组件库实战技巧与踩坑记录
前端·javascript·vue.js·typescript
刘延林.11 小时前
Visual Studio Code+PlatformIO + ESP32-S3 + Arduino 框架点亮一个小的led灯-测试
ide·vscode·编辑器
donecoding12 小时前
类型与语法的“直觉对齐”:TS 切入的 Go 语言初体验
前端·typescript·go
Dontla12 小时前
VSCode插件Git Graph介绍(Git可视化管理分支、可视化Git)
ide·git·vscode