johnsoncodehk / vue-tsc

vue-tsc --noEmit && vite build
https://www.npmjs.com/package/vue-tsc
MIT License
241 stars 6 forks source link

Thousands of TS errors #65

Closed Shinigami92 closed 3 years ago

Shinigami92 commented 3 years ago

My companies project uses vue-tsc ~0.3.0 and vscode-vue-languageservice ~0.27.7 Last week everything worked, but today (after weekend) I just run rm yarn.lock && yarn to update all dependencies and now when I run yarn vue-tsc --noEmit I get 3780 TS errors.

They mostly look like TS2304: Cannot find name 'XXX'. or TS2306: File 'XXX' is not a module.

But even when I pin the both deps, I still get these errors. Only when I reset my yarn.lock and package.json and then run yarn install --immutable then I don't get the errors.

But this or that way, vite dev server shows everything works normally.

Shinigami92 commented 3 years ago

See https://github.com/johnsoncodehk/volar/discussions/437 🤔 Could be related

johnsoncodehk commented 3 years ago

Replied, reproduce wanted. :S

Shinigami92 commented 3 years ago

Repro: https://github.com/Shinigami92/repro-vue-tsc-65/commits/master

Shinigami92 commented 3 years ago

I'm down from 3780 TS Errors to "only" 420 TS Errors 😔

There are only mainly two types of errors

  1. Normal variables/functions not found returned by the setup function
    error TS2304: Cannot find name 'xxx'.

  2. v-slot:activator="{ on }"

image

There is also one $t 👀 image


I think I will update the repro and tell you when it's ready

Shinigami92 commented 3 years ago

The second error occurred through tsconfig.json setting noUnusedLocals to true

Setting it to false, I'm down to 327 errors. Could you fix that? I would like to stay on "noUnusedLocals": true

... Will dig further down for the other errors ...

johnsoncodehk commented 3 years ago

Could you fix that? I would like to stay on "noUnusedLocals": true

I think this is correct report, if you have no use { on }.

Shinigami92 commented 3 years ago

I think this is correct report, if you have no use { on }.

But I have... that's the point ^^, otherwise I would remove it


The other errors are really random and I currently don't find out why the occur 🤔

I will update the repro now, but everything in it works...

Shinigami92 commented 3 years ago

Also before last thursday I didn't had all these issues, then some updates in volar and vue/vscode language server and vue-tsc happend, and after that it broke. But I also cannot pin versions or so. When I just update something and recreate the yarn.lock after that it's broken. 🙁

I would like to rollback to last thursday...

johnsoncodehk commented 3 years ago

I only see the declared but never read problem.

image image

Shinigami92 commented 3 years ago

Okay lets fix one by one

https://github.com/Shinigami92/repro-vue-tsc-65/commit/c8e965f497650d192e5ff5e1272cc4bef5672634

https://github.com/Shinigami92/repro-vue-tsc-65/blob/c8e965f497650d192e5ff5e1272cc4bef5672634/src/App.vue#L3-L7

image

Shinigami92 commented 3 years ago

I'm away for next hour. Not sure I will come back today, otherwise see you tomorrow 👋

Thx for all your work 💚

johnsoncodehk commented 3 years ago

It's because line 7 v-on="{ ...tooltip, ...menu }" don't have event name, so volar ignore this expression. What is the nameless event behavior?

Shinigami92 commented 3 years ago

I have one more step to success! I found out that the issue that all these variables cannot be found is based on one sub-sub component! This component uses some really special stuff, but seems to crash the parser and therefore cannot be compiled leading to un-compiled code for the components using it traversing up the tree to the root views. All views/components that has not this component in use anywhere are working just fine.

Now I need to find out what exactly the problem is.

Shinigami92 commented 3 years ago

It has something to do with following code

v-btn(icon, @click="currentPreviewIndex--", :disabled="currentPreviewIndex <= 0")
//-                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^~~~

But even when I try to reproduce it, it just works I'm so confused

It took me 2-3 hours to find me this code line

I think my workaround would be for now to move this condition to a computed and then use that Edit: ... yes the workaround works, no errors anymore

johnsoncodehk commented 3 years ago

It seem a pug parser problem, and working good in html. Will check it.

johnsoncodehk commented 3 years ago

We use HTMLDocument from vscode-html-languageservice to parse SFC, it detected <= is a html start tag, so all behind SFC blocks is broken. Don't know how to handle yet. :S

johnsoncodehk commented 3 years ago

Please track https://github.com/johnsoncodehk/volar/issues/451.