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

Cannot use the angle bracket syntax <> to assert a type #1706

Closed
John60676 opened this issue Aug 11, 2022 · 7 comments · Fixed by #1865
Closed

Cannot use the angle bracket syntax <> to assert a type #1706

John60676 opened this issue Aug 11, 2022 · 7 comments · Fixed by #1865

Comments

@John60676
Copy link

Before version 0.39.5 it works.

image

When I updated to version 0.40.x it didn't work

image

@linfei721
Copy link

我也遇到这个问题了,导致页面所有代码报错

@ghost
Copy link

ghost commented Aug 13, 2022

我也遇到这个问题了+1

@LuckingCat
Copy link

+1, 看了一天, 才发现是插件的问题

@Soviut
Copy link

Soviut commented Aug 22, 2022

Installing any version before prior to 0.40.0 fixed the problem for me.

On the "Uninstall" button, click the dropdown arrow and choose "Install another version". Then choose 0.39.5

image

@xiaoxiangmoe
Copy link
Collaborator

xiaoxiangmoe commented Sep 1, 2022

You can temporarily use as to do type assertion

const datas = reactive({
  roles: [] as Array<string>,
  entities: [] as Array<any>,
});

related eslint config: consistent-type-assertions with assertionStyle: "as".


This error occurs because the latest volar has changed the generation logic of virtual files in order to solve someother problems:

#823
#891
#462
#1321

So, the current phenomenon is that volar only allow syntax in tsx in .vue file.

@qgates
Copy link

qgates commented Sep 8, 2022

You can temporarily use as to do type assertion

@xiaoxiangmoe fine as a temporary workaround but not really a solution for large codebases. We shouldn't need a huge refactor to make perfectly valid code compatible with volar. Staying with 0.39.5 for now, is a fix coming?

@Soviut
Copy link

Soviut commented Sep 8, 2022

@qgates The issue is known and you'll see a related PR here when there's a fix. This project is maintained by a single developer so consider sponsoring them so they can dedicate more time to this project.

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 a pull request may close this issue.

6 participants