mxsdev / ts-type-explorer

VSCode Extension & utilities for exploring TypeScript type information
https://marketplace.visualstudio.com/items?itemName=mxsdev.typescript-explorer&ssr=false
159 stars 4 forks source link

feat: add `vue` support #45

Open zcf0508 opened 8 months ago

zcf0508 commented 8 months ago

I create a new typescript program by vue-tsc and then get the type from virtual file.

image

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

zcf0508 commented 8 months ago

So far, I have noticed two major issues.

  1. Before obtaining the type from a vue file, you are necessary to open ajs or ts file to start the vscode TS language service so that the types in the vue file can be obtained normally.
  2. It seems to be incompatible with a monorepo. It works, just need open a js or ts file like 1.
sxzz commented 8 months ago

AFAIK Volar 2.0 is released recently. The API may be changed a lot. I'm not sure how should this PR be done.

zcf0508 commented 8 months ago

@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.

zcf0508 commented 8 months ago

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.

zcf0508 commented 7 months ago

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

zcf0508 commented 5 months ago

Update Volar to v2.2.0-alpha.12, thanks for @johnsoncodehk .

typescript-explorer-0.4.2-vue-ts5.vsix.zip

johnsoncodehk commented 5 months ago

@zcf0508 I can't build this branch successfully locally, can I get some guidance?

zcf0508 commented 5 months ago

@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
zcf0508 commented 5 months ago

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 !

typescript-explorer-0.4.2-vue-ts5.vsix.zip

xzhdev commented 5 months ago

volar 扩展已经废弃,目前使用Vue - Official

zcf0508 commented 5 months ago

volar 扩展已经废弃,目前使用Vue - Official

@xzhdev 只是改了名字而已,扩展的标识还是 vue.volar

image

xzhdev commented 5 months ago

@zcf0508 好的哥,但是我用了你的vsix后,vue中ts类型显示error

Snipaste_2024-05-09_14-36-55
zcf0508 commented 5 months ago

@xzhdev 图片裂了😂,可以的话给个最小复现

xzhdev commented 5 months ago

@xzhdev 图片裂了😂,可以的话给个最小复现

图片能看见了不

zcf0508 commented 2 months ago

Fixed location error, now goToDefinition works fine. And https://github.com/mxsdev/ts-type-explorer/pull/45#issuecomment-2102037309 this issue has been resolved.

image

Try typescript-explorer-0.4.2-vue-ts5.zip

xzhdev commented 2 months ago

修复了位置错误,现在goToDefinition工作正常。并且#45(评论)此问题已解决。

图像

尝试typescript-explorer-0.4.2-vue-ts5.zip

@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中类型支持都没有了,真奇怪