Type checking for template expressions #681
This is work in progress PR which enables Vetur to type check template expressions.
The approach is the same as I wrote in #209 - transforming template html to TypeScript AST, then type checking it. I use
With this feature, we may also able to provide completion in template and component props type checking but I would like to leave them for another PR since this PR is already large without them
BTW, should we disable this feature in default and let the users enable it by configuration?
TODO for this PR
Remaining Tasks (after this PR)
First -- great work! Thanks for pushing this forward!
Yes. We should put an option like
But I think currently the biggest problem is that there is no longer a clean separation of mode, as the type checking exists on both template/script modes. If we want to do suggestion/hovering and other LS features, it makes sense to create a
Let's aim for a MVP, where we have:
Can you add me to your fork so I can push changes? I'll have some time to look deeper into this PR this weekend. Before that I'll spend some time looking into some other smaller, long-standing bugs...
@HerringtonDarkholme Yeah I agree we should start adding some integration tests running VLS against real-world repos. This is one of the things I plan to look into this month.
I see, the problem is you try to set zero pos for all the template-script code, so TS resolved them to invalid locations and throws there.
I think we can try maybe appending these lines to the end of file and map them back? This way we can get other features such as hover, jump to definition (from template), etc working as well. I'll give it a try.
I also tweaked template transformer a bit to avoid false-positive diagnostics about
Merged. @ktsn Congratulations
Do you mind creating a new issue to track what you plan to do? I can add to that issue my side of things.
From my perspective I'd like to see if I can make completion work from the