Open axetroy opened 1 year ago
And I found this in sourcecode
Maybe typescript 5.0 got a breaking change.
And I debug in vscode and print to console, make confirm this
createLanguageServiceSourceFile: [Getter],
I research the code of Typescript.
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __esm = (fn, res) => function __init() {
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
};
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
// src/typescript/_namespaces/ts.ts
var ts_exports3 = {};
__export(ts_exports3, {
// ...
createLanguageServiceSourceFile: () => createLanguageServiceSourceFile
})
It use Object.defineProperty
to define a exports getter.
so, The changes below should fix this issue
var __export = (target, all) => {
for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
+ __defProp(target, name, { get: all[name], enumerable: true, configurable: true });
};
- (tsModule as any).createLanguageServiceSourceFile = createLanguageServiceSourceFile;
+ Object.defineProperty(tsModule, 'createLanguageServiceSourceFile', { get: () => createLanguageServiceSourceFile, enumerable: true })
- (tsModule as any).updateLanguageServiceSourceFile = updateLanguageServiceSourceFile;
+ Object.defineProperty(tsModule, 'updateLanguageServiceSourceFile', { get: () => updateLanguageServiceSourceFile, enumerable: true })
I try to patch the Typescript exports in node_modules
but I found this doesn't work because tsModule is find from package env.
It may use vscode build-in typescript version, while it great then 5.0.0, vetur will crash and unusable
if you are using typescript(or your vscode build-in typescript) that lower then 5.0.0, the extension still working.
othersize:
replace the code like before I write
and use it in .vscode/setting.json
"typescript.tsdk": "node_modules\\typescript\\lib"
restart Vue language Server and you will get this error:
TypeError: Cannot read properties of undefined (reading 'length')
at F (c:\Users\Admin\.vscode-server\extensions\octref.vetur-0.37.3\server\dist\vls.js:888:963)
at getServiceHost (c:\Users\Admin\.vscode-server\extensions\octref.vetur-0.37.3\server\dist\vls.js:888:655)
at hb.init (c:\Users\Admin\.vscode-server\extensions\octref.vetur-0.37.3\server\dist\vls.js:895:1259)
at createProjectService (c:\Users\Admin\.vscode-server\extensions\octref.vetur-0.37.3\server\dist\vls.js:895:8486)
at _T.getProjectService (c:\Users\Admin\.vscode-server\extensions\octref.vetur-0.37.3\server\dist\vls.js:896:10802)
at async _T.doValidate (c:\Users\Admin\.vscode-server\extensions\octref.vetur-0.37.3\server\dist\vls.js:896:18216)
at async _T.validateTextDocument (c:\Users\Admin\.vscode-server\extensions\octref.vetur-0.37.3\server\dist\vls.js:896:18090)
[Info - 14:40:39] Connection to server got closed. Server will restart.
[Error - 14:40:39] Request textDocument/documentSymbol failed.
It comes from:
initialProjectFiles
is undefined
This can not be fixed with a little patch.
It can not be fix from vscode extension, it should be fix from upstream(Typescript) and then update vetur to typescript@^5.0.0
Rollback your vscode to older version to make it works again
@yoyo930021 This is my investigation. Are you interested in investigating and solving it? The vetur has completely failed to work on my vscode.
I think you can change title for issue. I will try to fix it when I have time.
Just wanted to confirm that this is reproducible. When using TypeScript 5.x, vetur would hang. Switching back to 4.9.4 fixed it.
The exported API is no longer defined as a "configurable" object
https://github.com/microsoft/TypeScript/issues/52847
ref: https://github.com/mrmckeb/typescript-plugin-css-modules/pull/211/files
Vetur relies deeply on this API.
We use it to inject Vue.extends
to Vue SFC script block.
It will be quite troublesome for fix it.
if I understand correctly, we cannot yet use Vetur with typescript 5.*, is this the current state?
Anything new on this issue?
I also wonder if there is a temporary solution to use TypeScript 5 with Vetur since I'm dependent on Vue.extend
Volar is unsuitable in my case. 👀
Same probem, I just want to make Vetur works in my vue 2 project ..
Vetur: Restart VLS
Info
Output
Problem
The loading status in status bar is always loading.
Because the Vue Language Server can not start correctely
Reproducible Case