当前位置:网站首页>Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file
Install the typescript environment and enable vscode to automatically monitor the compiled TS file as a JS file
2022-06-29 12:52:00 【Front end technical station】
One 、 Preface
Xiaobian recently started to learn typescript, Everybody knows that ,typescript yes vue3 Basic association of , More tacit cooperation . It's like vue2 and js equally !typescript Unlike js That way, the browser can directly interpret , We need to put ts File compiled into js file , So that the browser can interpret . So we're going to install it ts Environment and automatic compilation , To facilitate our follow-up study , You don't have to write a ts The file is being compiled manually !
Two 、 install typescript Environmental Science
There must be node Environment !
win + R Input cmd
npm install -g typescript-g representative global Global installation
View version
tsc -v
3、 ... and 、VSCode Configure automatic monitoring compilation
1. Create a new folder

2. Open at terminal

3. Initialize configuration file
tsc --init
4. Edit profile
52 Row modification generates js The file storage location is :json Of the directory where the folder is located js Under the folder ,js None of them will help us create !
79 OK, let's turn off grammar checking , Make yourself at home !( Set according to personal preference )

5. Turn on automatic compilation
find terminal , Click on Run the task 
Click on Show all tasks 
Find what you want to monitor json file

There is an error :
error TS18003: No inputs were found in config file
'd:/file-wang/vue/code/test/tsconfig.json'.
Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["./js"]'.
Let's not worry , This is not monitored ts file , So the hint , We don't care , Write a ts Test it !
Four 、 test
1. To write ts file
newly build test.ts
(() => { function helloWord(str:string){ return ' This is the first one ts Program :' + str
} var text = 'helloword'
console.log(helloWord(text))
})();We found that ,js Folder has been compiled into js The file !

2. To write html file
Let's introduce js Under folder js file !
<!DOCTYPE html><html lang="en"><head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title></head><body>
<script src="./js/test.js"></script></body></html>3. Browser Test
We are test.html Press and hold the shortcut key on the page :alt + B Open in browser times html file
We F12 See if you have output : This is the first one ts Program :helloword
5、 ... and 、 summary
This completes the basic installation and configuration of automatic monitoring ts File compiled into js file , Remember to click three times to help your little friend ! Thank you for your support !!
边栏推荐
- 百度云盘不限速下载大文件(2021-11亲测有效)
- C#通过线索二叉树进行中序遍历输出
- go 学习-搭建开发环境vscode开发环境golang
- 2022.6.28-----leetcode. three hundred and twenty-four
- Go Senior Engineer required course | I sincerely suggest you listen to it. Don't miss it~
- qt json
- Principle and process of MySQL master-slave replication
- Cache consistency, delete cache, write cache, cache breakdown, cache penetration, cache avalanche
- MySQL主从同步之 异步复制 半同步复制 全同步复制
- Gbase8s database select has order by Clause 2
猜你喜欢

推荐模型复现(四):多任务模型ESMM、MMOE

推荐模型复现(二):精排模型DeepFM、DIN

如何計算win/tai/loss in paired t-test

智能指标驱动的管理和决策平台 Kyligence Zen 全新上线,限量内测中

QQ集体被盗号,猝不及防的大型社死名场面
![[intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial](/img/00/9a6d17844b88f6921ad488f4975684.png)
[intelligent QBD risk assessment tool] Shanghai daoning brings you leanqbd introduction, trial and tutorial

qt 自定义控件 :取值范围

Unexpected ‘debugger‘ statement no-debugger

File contained log poisoning (user agent)

After class assignment of module 5 of the construction practice camp
随机推荐
C#通过中序遍历对二叉树进行线索化
Pangolin compilation error: 'numeric_ limits’ is not a member of ‘std’
Gbase8s database for read only clause
Lm07 - detailed discussion on cross section strategy of futures
Cmake error
How to fix ora-01017: invalid user name / password login denied
Newton inequality
如果我在深圳,到哪里开户比较好?另外想问,现在在线开户安全么?
Go Senior Engineer required course | I sincerely suggest you listen to it. Don't miss it~
[comprehensive case] credit card virtual transaction identification
Inferiority complex and transcendence the meaning of life to you
缓存一致性,删除缓存,写入缓存,缓存击穿,缓存穿透,缓存雪崩
ZALSM_EXCEL_TO_INTERNAL_TABLE 导入数据大问题解决
Gbase 8s extended external connection 1
Syntax of gbase8s database incompatible with for update clause
倍福TwinCAT3 的OPC_UA通信测试案例
倍福控制器连接松下EtherCAT伺服注意事项
C#实现二叉排序树定义、插入、构造
Qt中的UI文件介绍
How to fix ORA-01017:用户名/口令无效 登录拒绝