React react did XXX. I’m a vue user.
Yesterday WHEN I looked in the log, I suddenly found the word vUE. I couldn’t believe it, so I quickly took out my reading glasses and read the content clearly.
preserveValueImports
This is a new option in tsconfig. What does it do? If an imported variable is not used, ts will delete it after compilation. This option tells TS to “mind your own business “.
For example, this code will be deleted when ts is compiled by default:
import { Animal } from "./animal.js";
eval("console.log(new Animal().isDangerous())");
Copy the code
Eval may not be useful for us, but how about the new syntax of VUe3, sugar setup?
<! -- A .vue File -->
<script setup>
import { someFunc } from "./some-module.js";
</script>
<button @click="someFunc">Click me!</button>
Copy the code
You introduced variables in script, but they didn’t work. Ts can’t detect them in the template, so you need to open “preserveValueImports”.
More TS updates
Recently, I have read all the ts update logs and compiled them into a note to share with you. github.com/any86/ts-lo…
Learn TS together
Thank you for your reading. If you have any questions, you can add me to the wechat group, and I will pull you into the wechat group (Because Tencent limits the number of wechat groups to 100, when the number exceeds 100, you must be joined by group members).
github
My own open source is based on TS, please visit github.com/any86