当前位置:网站首页>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-22 22:56:00 【Xiao Wang with hair loss】
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 !!
Those who are destined can see !!!
Click on the access ! Make up your own website , There are also many good articles in it !
边栏推荐
- Seriously, the hang up of the kotlin collaboration process is not so mysterious (principle)
- R language builds a binary classification model based on H2O package: using H2O GLM constructs regularized logistic regression model and uses H2O AUC value of AUC calculation model
- 2020-12-20
- Generate detailed API and parameters of QR code using qrcodejs2
- 2021-07-27
- Rapideye, spot satellite remote sensing image data
- Developing salary management system based on C language course paper + source code and executable EXE file
- The xinjietu x70s has been listed for 87900 times and has leapfrogged the class in space safety. It is worthy of being a 7-seat SUV of the National University of China
- [interpretation of the paper] sort out the papers on the vision based autonomous landing platform of UAV
- Next permutation [give play to subjective initiative to discover laws]
猜你喜欢

What are the methods of software stress testing and how to select a software stress testing organization?
![[interpretation of the paper] sort out the papers on the vision based autonomous landing platform of UAV](/img/a5/bfa011c961b8f05348f9905fe3d996.png)
[interpretation of the paper] sort out the papers on the vision based autonomous landing platform of UAV

General trend wisdom to create inclined model and cut monomer

2021-05-02
![组合总数[标准回溯 + 回溯技巧--降低栈深度]](/img/88/3a07589bf8edab618139b1bf1680e8.png)
组合总数[标准回溯 + 回溯技巧--降低栈深度]

2021-05-02

5分钟快速上线Web应用和API(Vercel)

The relationship between derivative and differential of function

2021-08-21
![[Li mu] how to read papers [intensive reading of papers]](/img/86/4894bdef31d47d3f9bf3206b997eed.jpg)
[Li mu] how to read papers [intensive reading of papers]
随机推荐
Lua -- iterator, module, meta table
Rendu stéréo
Generate detailed API and parameters of QR code using qrcodejs2
2020-12-20
2021-08-22
Uniapp applet mall develops thinkphp6 points mall, group purchase and seckill packaged app
LinkedList source code analysis
Use full function simulation design method
NFT can only be viewed from afar, but not blatantly played
2021-04-14
Atcoder abc256 full problem solution (interval merging template, matrix fast power optimization DP, line segment tree...)
Rapideye, spot satellite remote sensing image data
The required reading for candidates | PMP the test on June 25 is approaching. What should we pay attention to?
2020-12-04
2020-12-20
2021-04-14
2021-04-16
Experiment 4 operation comparison between NoSQL and relational database
Why is yuancosmos so popular? Is the 10trillion yuan shouted by the market boasting or the truth?
[ROS introduction] cmakelist Txt and packages XML interpretation