Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add vue support #45

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

feat: add vue support #45

wants to merge 10 commits into from

Conversation

zcf0508
Copy link

@zcf0508 zcf0508 commented Jan 26, 2024

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?

dsherret/ts-morph#1310

@zcf0508
Copy link
Author

zcf0508 commented Jan 26, 2024

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
Copy link

sxzz commented Jan 26, 2024

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
Copy link
Author

zcf0508 commented Jan 27, 2024

@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
Copy link
Author

zcf0508 commented Feb 1, 2024

I'm waiting for that vue-tsc releases the update with volar.js 2.0 and volar.js exposes FileRegistry by merging volarjs/volar.js#128 or other ways.

@zcf0508
Copy link
Author

zcf0508 commented Mar 2, 2024

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
Copy link
Author

zcf0508 commented Apr 30, 2024

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

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

@johnsoncodehk
Copy link

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

@zcf0508
Copy link
Author

zcf0508 commented May 1, 2024

@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
Copy link
Author

zcf0508 commented May 1, 2024

Since vue.volar inject the language to program (vuejs/language-tools#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
Copy link

xzhdev commented May 9, 2024

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

@zcf0508
Copy link
Author

zcf0508 commented May 9, 2024

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

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

image

@xzhdev
Copy link

xzhdev commented May 9, 2024

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

@zcf0508
Copy link
Author

zcf0508 commented May 9, 2024

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

@xzhdev
Copy link

xzhdev commented May 9, 2024

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

图片能看见了不

@zcf0508
Copy link
Author

zcf0508 commented Jul 25, 2024

Fixed location error, now goToDefinition works fine. And #45 (comment) this issue has been resolved.

image

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

@xzhdev
Copy link

xzhdev commented Aug 5, 2024

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

@zcf0508
Copy link
Author

zcf0508 commented Oct 29, 2024

typescript-explorer-0.4.2-vue-ts5.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants