ts-type-explorer icon indicating copy to clipboard operation
ts-type-explorer copied to clipboard

feat: add `vue` support

Open zcf0508 opened this issue 1 year ago • 16 comments

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 avatar Jan 26 '24 07:01 zcf0508

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.

zcf0508 avatar Jan 26 '24 13:01 zcf0508

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 avatar Jan 26 '24 14:01 sxzz

@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 avatar Jan 27 '24 02:01 zcf0508

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 avatar Feb 01 '24 06:02 zcf0508

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 avatar Mar 02 '24 09:03 zcf0508

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

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

zcf0508 avatar Apr 30 '24 06:04 zcf0508

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

johnsoncodehk avatar Apr 30 '24 19:04 johnsoncodehk

@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 avatar May 01 '24 01:05 zcf0508

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

zcf0508 avatar May 01 '24 14:05 zcf0508

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

xzhdev avatar May 09 '24 06:05 xzhdev

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

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

image

zcf0508 avatar May 09 '24 06:05 zcf0508

@zcf0508 好的哥,但是我用了你的vsix后,vue中ts类型显示error Snipaste_2024-05-09_14-36-55

xzhdev avatar May 09 '24 06:05 xzhdev

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

zcf0508 avatar May 09 '24 06:05 zcf0508

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

图片能看见了不

xzhdev avatar May 09 '24 06:05 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.

image

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

zcf0508 avatar Jul 25 '24 16:07 zcf0508

修复了位置错误,现在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中类型支持都没有了,真奇怪

xzhdev avatar Aug 05 '24 02:08 xzhdev