当前位置:网站首页>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 !
边栏推荐
- Lua -- iterator, module, meta table
- 2021-03-06
- MySQL constraints
- leetcode. 11 --- container with the most water
- Lua-- use of data types, variables, loops, functions and operators
- Mysql database design
- How much do you know about the cause of amplifier distortion?
- R language data preprocessing, converting type variables into factor variables, converting data sets into H2O format, and dividing data sets (training set, test set, verification set)
- What if the SQL execution plan of the production system suddenly becomes worse?
- A group of K overturned linked lists [disassembly / overturning / assembly of linked lists]
猜你喜欢

2021-04-14

Experiment 4 operation comparison between NoSQL and relational database
![[ROS introduction] cmakelist Txt and packages XML interpretation](/img/37/24ce4be244ea56c2c84342492fccd4.png)
[ROS introduction] cmakelist Txt and packages XML interpretation

Three cache methods and principles

redis 报错解决与常用配置

What are the methods of software stress testing and how to select a software stress testing organization?

2021-04-14
Several ways of redis persistence -- deeply parsing RDB
![[ongoing update...] 2021 National Electronic Design Competition for college students (III) interpretation of the anonymous four axis space developer flight control system design](/img/5d/71c75a3622f7814f385d04b6148074.png)
[ongoing update...] 2021 National Electronic Design Competition for college students (III) interpretation of the anonymous four axis space developer flight control system design

The mental process and understanding of visual project code design
随机推荐
Zynq ultrascale + rfsoc zcu111 RF clock tree learning 1
Learn redis with you (11) -- redis distributed lock
Plan and change of continuous repair
《强化学习周刊》第50期:SafeRL-Kit、GMI-DRL、RP-SDRL & 离线元强化学习
The mental process and understanding of visual project code design
leetcode. 11 --- container with the most water
Redis error reporting and common configurations
Reasons for the failure of digital transformation and the way to success
Total number of combinations [standard backtracking + backtracking techniques -- reducing stack depth]
From 11 hours to 25 seconds -- is there room for optimization?
Case 2 of SQL performance degradation caused by modifying implicit parameters
Task cache compilation caused by gradle build cache
Some shaders in AB package do not trigger the callback of ipreprocessshaders
Fundamentals of shell programming (Part 7: branch statement -if)
新捷途X70S上市8.79万起,空间安全越级,不愧是网红国民大7座SUV
[ongoing update...] 2021 National Electronic Design Competition for college students (III) interpretation of the anonymous four axis space developer flight control system design
2020-12-20
立體渲染
2021-08-22
How to change the dial on the apple Watch