vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.55k stars 373 forks source link

fix(language-core): set __VLS_template as an asynchronous function #4413

Closed zhiyuanzmj closed 3 weeks ago

zhiyuanzmj commented 1 month ago

__VLS_template should be an asynchronous function.

Prevent the compile error:

 'await' expressions are only allowed within async functions and at the top levels of modules.
image
zhiyuanzmj commented 4 weeks ago

Or maybe we should move __VLS_internalComponent outside the __VLS_template function. Just like in v1.8.17.

johnsoncodehk commented 3 weeks ago

Thank you for the PR! But this caused an issue where incorrect usage of await cannot be detected in the template. I just added a test in the master branch.

johnsoncodehk commented 3 weeks ago

Or maybe we should move __VLS_internalComponent outside the __VLS_template function.

This is a good point, but requires special handling for class component codegen, so it's better not to do this to avoid further complexity.