1

This time typescript (4.5) arranged for vue3 clearly and clearly

Looking at the update log of ts before, I can always see that this time I did xxx for "react". As a user of vue, I am envious.

through the log yesterday, I suddenly found the words 161bfd59f51529 vue , I couldn't believe it, I quickly took out my reading glasses to see the content clearly.

image

preserveValueImports

This is a new option in tsconfig. What is it for? Simply put, if the imported variable is not used in the previous version of ts, it will be deleted after ts is compiled. With this option, can tell ts "don't be nosy" .

For example, this kind of code will be deleted by default after ts is compiled:

import { Animal } from "./animal.js";
eval("console.log(new Animal().isDangerous())");

We may not use eval, but vue3's new syntactic sugar setup can you use it?

<!-- A .vue File -->
<script setup>
  import { someFunc } from "./some-module.js";
</script>
<button @click="someFunc">Click me!</button>

You have introduced variables in the script, but they are useless. Although they are used in the template, ts cannot be detected, so you need to enable "preserveValueImports".

More ts update content

Recently, in order to check the omissions, I read all the update logs of ts, and organized them into notes, and share them.
https://github.com/any86/ts-log-cn

image

Learn ts together

image

Thank you for reading. If you have any questions, you can add me to WeChat. I will pull you into the WeChat group (Because Tencent has a limit of 100 people in WeChat groups, after more than 100 people must be pulled in by group members)

github

My personal open source is based on ts, welcome everyone to visit https://github.com/any86


铁皮饭盒
5k 声望1.2k 粉丝

喜欢写程序: [链接]