ts-type-explorer
ts-type-explorer copied to clipboard
feat: add `vue` support
I create a new typescript program by vue-tsc
and then get the type from virtual file.
I tried to get the type from volar
but I have no idea about how volar
resolve the type. It seems that only provide the information of type by getTypeDefinitionAtPosition
or getDefinitionAtPosition
function to vscode
. I don't know.
I think this is an important feature to debug type with vue
file. Could @sxzz and @johnsoncodehk review the code together?
https://github.com/dsherret/ts-morph/issues/1310
So far, I have noticed two major issues.
- Before obtaining the type from a
vue
file, you are necessary to open ajs
orts
file to start the vscode TS language service so that the types in thevue
file can be obtained normally. - ~~It seems to be incompatible with a monorepo.~~ It works, just need open a
js
orts
file like 1.
AFAIK Volar 2.0 is released recently. The API may be changed a lot. I'm not sure how should this PR be done.
@sxzz I saw the update for volar
, but no new version of vue-tsc
based on volar
2.0 has been released yet.
It seems that it should not be a very difficult thing to do, I will follow up later on.
I'm waiting for that vue-tsc
releases the update with volar.js
2.0 and volar.js
exposes FileRegistry
by merging https://github.com/volarjs/volar.js/pull/128 or other ways.
As vue-lanugage-tools
updated 2.0, there is a build of this extension available for everyone to try.
typescript-explorer-0.4.2-vue-ts5.zip
@sxzz @johnsoncodehk
Update Volar to v2.2.0-alpha.12
, thanks for @johnsoncodehk .
@zcf0508 I can't build this branch successfully locally, can I get some guidance?
@johnsoncodehk Right, this branch only add vue support but it can't build locally. You can checkout to https://github.com/zcf0508/ts-type-explorer/tree/feat/vue%2Bts5 this branch.
yarn
cd package/api
yarn build
cd ..
cd typescript-pblugin
npx tsc -d
cd ..
cd typescript-explorer-vscode
yarn package
Since vue.volar
inject the language
to program (https://github.com/vuejs/language-tools/pull/3963), now if you install the vue.volar
extension above 2.0.16, the extension can get type information from volar extension and recreating a vue language program is unnecessary. Thanks for @johnsoncodehk !
volar 扩展已经废弃,目前使用Vue - Official
volar 扩展已经废弃,目前使用Vue - Official
@xzhdev 只是改了名字而已,扩展的标识还是 vue.volar
@zcf0508 好的哥,但是我用了你的vsix后,vue中ts类型显示error
@xzhdev 图片裂了😂,可以的话给个最小复现。
Fixed location error, now goToDefinition
works fine. And https://github.com/mxsdev/ts-type-explorer/pull/45#issuecomment-2102037309 this issue has been resolved.
修复了位置错误,现在
goToDefinition
工作正常。并且#45(评论)此问题已解决。
@zcf0508 我使用https://github.com/user-attachments/files/16380951/typescript-explorer-0.4.2-vue-ts5.zip 安装后没有效果,我用你的https://github.com/zcf0508/ts-type-explorer/tree/feat/vue%2Bts5 分支运行npm run package 打包visx后安装,vue中类型支持都没有了,真奇怪