vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.78k stars 390 forks source link

Error: `getClassOffset` is not a function (from element.ts) #4759

Closed J-Sek closed 3 weeks ago

J-Sek commented 3 weeks ago

Vue - Official extension or vue-tsc version

2.1.2

VSCode version

1.92.2

Vue version

3.4.38

TypeScript version

5.5.4, 5.4.5

System Info

System:
    OS: Linux 6.8 / Zorin OS 17.1
    CPU: i5-13600KF
    Memory: 18 / 32 GB
    Container: Yes
  Binaries:
    Node: 18.20.4 - ~/n/bin/node
    npm: 10.7.0 - ~/n/bin/npm
    bun: 1.1.26 - ~/.bun/bin/bun

Steps to reproduce

Pug version: 3.0.3, 3.0.2

What is expected?

Type inference should work as usual - in Pug templates.

What is actually happening?

Type inference stopped working for Pug templates.

Link to minimal reproduction

Nuxt starter project with Pinia and custom plugin

Any additional comments?

Following error does not appear on the minimal repro, but is constantly thrown on my main large project.

[Error - 11:30:20 AM] Server process exited with code 0.
[Vue Named Pipe Client] Deleting: /tmp/vue-named-pipe-2.1.2-configured-0
[Vue Named Pipe Client] Deleting: /tmp/vue-named-pipe-2.1.2-inferred-0
[Vue Named Pipe Client] Connected: /tmp/vue-named-pipe-2.1.2-inferred-0 in 2ms
[Vue Named Pipe Client] Connected: /tmp/vue-named-pipe-2.1.2-inferred-1 in 2ms
[Vue Named Pipe Client] Ready: /tmp/vue-named-pipe-2.1.2-inferred-0 in 3ms
[Vue Named Pipe Client] Ready: /tmp/vue-named-pipe-2.1.2-inferred-1 in 3ms
[Vue Named Pipe Client] Connected: /tmp/vue-named-pipe-2.1.2-configured-0 in 1ms
[Vue Named Pipe Client] Connected: /tmp/vue-named-pipe-2.1.2-inferred-2 in 1ms
[Vue Named Pipe Client] Ready: /tmp/vue-named-pipe-2.1.2-configured-0 in 1488ms
[Vue Named Pipe Client] Ready: /tmp/vue-named-pipe-2.1.2-inferred-2 in 1488ms
TypeError: a is not a function
    at fwe (/home/me/.vscode/extensions/vue.volar-2.1.2/dist/server.js:220:4828)
    at fwe.next (<anonymous>)
    at hB (/home/me/.vscode/extensions/vue.volar-2.1.2/dist/server.js:220:2167)
    at hB.next (<anonymous>)
    at rB (/home/me/.vscode/extensions/vue.volar-2.1.2/dist/server.js:220:1243)
    at rB.next (<anonymous>)
    at ki (/home/me/.vscode/extensions/vue.volar-2.1.2/dist/server.js:219:5773)
    at ki.next (<anonymous>)
    at ki (/home/me/.vscode/extensions/vue.volar-2.1.2/dist/server.js:219:5470)
    at ki.next (<anonymous>)

image

element.ts:605

TypeScript throws [error] TSServer exited. Code: null. Signal: SIGTERM, but I somehow doubt it is the exact cause.

J-Sek commented 3 weeks ago

I wouldn't mind digging deeper, debugging. Is there a way to use unminified source code?

KazariEX commented 3 weeks ago

I guess it happened on the pug template. #4652

https://github.com/vuejs/language-tools/blob/cb5d5a656e95bcd778b716fe2015490aecd7baff/packages/language-core/lib/codegen/template/element.ts#L618

KazariEX commented 3 weeks ago

If you are willing, you can try forking this repository and debugging it locally!

J-Sek commented 3 weeks ago

I guess it happened on the pug template. #4652

Yes, I have updated the main description. Thanks for linking existing PR... but is it a part of 2.1.2 release or not yet? I'm confused.

KazariEX commented 3 weeks ago

Yes, it was merged into 2.1.0

KazariEX commented 3 weeks ago

Try install @vue/language-plugin-pug and adding it to tsconfig.json:

"vueCompilerOptions": {
  "plugins": [
    "@vue/language-plugin-pug"
  ]
}
J-Sek commented 3 weeks ago

Great advice! Updating @vue/language-plugin-pug to 2.1.2 fixes the exception.

I don't like all that plugins and things like $router are still underlined with red squigglies, but it's a different issue.