-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add native TS support for .vue files #238
Comments
Let's go with Anyone up for this? It should be trivial. |
For reference see the |
Actually, I do not think this is anything to do with |
Ok, so I figured out one way to do this. We can use this kind of thing to get errors. The downside is we must write the TS to a file to be consumed by this - not ideal for perf. But I will experiment. Most likely someone who works on Vetur has already solved this problem. I will ask them about it. I will make a POC you can enable with a flag and we can release v4. Improving it can be a minor release. I also fixed CI (I think). PR coming in the next day or so. |
If we're going with ts-jest, it should not fail. You can write TS code that won't compile and it'll pass unit tests. ts-jest doesn't use the typescript compiler. This was the difference between ts-jest and babel-jest's expected behavior |
I think the dream is that we listen to the user's existing settings and use the ts-jest or babel-jest settings they have. If TS users want their stuff to fail to compile during unit tests, then they want that for their SFCs, too |
Yep, I think we should just inherit the users' Anything else we will need to grab from their ts-jest settings? |
To be correct, There is one thing to use |
I got this working here @ahnpnl #239 not really ideal, but we just rip out the Last thing I need to change is to inherit some settings from |
Just FYI from So I can see the approach you are using in #239 is similar to
From #239 I don't see anywhere using |
So we need to check the user's Reflecting on this more, although Maybe we just have a similar option users can set for
And go with that. Coupling to another project's config (eg @JessicaSachs what do you think? What we have here does satisfy the goal of "build in TS support". We just need to decide if we want the default to be to typecheck or not. |
I can summarize these below options:
Caveats with only type checking without using ts-jest is losing some typescript functionalities. Now ts-jest has a stable structure so these 2 modes of isolatedModules won’t change anymore (unless typescript removes their apis) These are all the options I can think of from ts-jest side. |
Ok, cool. ATM we do not delegate to ts-jest. I don't know enough about jest transformers to implement this at the moment. Maybe in the future, we can collab on this. For now I am happy with the support here, so I will prepare to release this. Are you on any discord servers? I may ask you for help with improving ts-jest support for Vue files in the future. |
Ye you can contact me on discord @ahn#1702 or ts-jest Slack (link in ts-jest README). I am curious about working a different file extension like .vue so trying out with vue is also in my to-do list. The goal is make a generic approach for other file extensions later which are not js or ts. |
Basically we rip out the |
you can use memory cache for that, see https://stackoverflow.com/questions/53733138/how-do-i-type-check-a-snippet-of-typescript-code-in-memory . I just tried out the codes provided there and it works. The example output like this
But to put that into a release, that example solution needs some fine-tunings :) |
Hi @ahnpnl , I am spending some time on this project now. I have another question, which I am unsure how to resolve. If I have many components, they all import the same module (say, vue). When I set my config to I have made a reproduction here: #249 Running the tests for this repro is pretty annoying, I had to do some hacks to get it working locally (I always hack this repo to do dev, idk how other people are doing it). I figured out might have some ideas around this? Just force it to compile to |
Indeed I see with Side information: I have checked
These tests don't require an actual physical file path but just simply need the file content. You can try out |
there is another way to tackle the problem happening to |
Would this fix the issue of casts in vue files being compiled as jsx and crashing? vuejs/vue-test-utils#1358 |
I'm having the same issue here: vuejs/vue-test-utils#1358 |
What does that issue have to do with this issue? |
Decide between ts-jest and babel-jest
The text was updated successfully, but these errors were encountered: