Oct 11, 2022
0
Level 11
Laravel Mix + TypeScript + Vue - Incorrect Error Lines
I'm currently using Laravel Mix to compile our assets, as opposed to Vite. We're using Vue SFCs and TypeScript. An example component is:
<script setup lang="ts">
let someVar: boolean = true;
someVar = 'testing';
</script>
As expected, the code above would produce a type error when compiling with npm run dev. However, the lines reported in the error aren't accurate, so it makes things a bit of a hassle to debug. The output would be something like:
ERROR in /var/www/html/resources/components/TestFile.vue.ts
10:4-11
[tsl] ERROR in /var/www/html/resources/components/TestFile.vue.ts(10,5)
TS2322: Type 'string' is not assignable to type 'boolean'.
From my understanding, this is saying it's on line 10, but it's not. I also notice that it's talking about a TestFile.vue.ts rather than the original TestFile.vue file, so that could be the reason. But I'm still unsure of how to resolve this situation. Has anyone run into this issue before or have any advice?
Thanks in advance.
Please or to participate in this conversation.