-
Notifications
You must be signed in to change notification settings - Fork 257
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
Typescript interface error RouterLink.d.ts #143
Comments
This has to do with I have the same issue. I tried downgrading vue to beta.12, but I now have other typing issues. I'm ending up testing vue3 without type checks |
That (may) fix it. I will try repro tonight and see if it does. I will do a release for the latest Vue 3 beta in the next day or two! We just merged up something that was blocking this. |
Alpha 7 is out now: https://github.com/vuejs/vue-test-utils-next/releases/tag/2.0.0-alpha.7 Can you see if this resolves your issue? |
@rtbo can you give this another try? |
Same problem with Repro: git clone [email protected]:rtbo/testvue3-ts
cd testvue3-ts
yarn install
yarn test:unit
ERROR Failed to compile with 2 errors
error in /home/remi/dev/test/testvue3-ts/node_modules/@vue/test-utils/dist/components/RouterLinkStub.d.ts
ERROR in /home/remi/dev/test/testvue3-ts/node_modules/@vue/test-utils/dist/components/RouterLinkStub.d.ts(5,12):
5:12 Generic type 'ComponentOptionsBase<Props, RawBindings, D, C, M, Mixin, Extends, E, EE>' requires between 8 and 9 type arguments.
3 | } & {}, unknown, unknown, {}, {}, Record<string, any>, import("vue").VNodeProps & {
4 | to: any;
> 5 | } & {}>) & import("vue").ComponentOptionsBase<Readonly<{
| ^
6 | to: any;
7 | } & {}>, unknown, unknown, {}, {}, Record<string, any>, string> & {
8 | props: {
error in /home/remi/dev/test/testvue3-ts/tests/unit/example.spec.ts
ERROR in /home/remi/dev/test/testvue3-ts/tests/unit/example.spec.ts(8,34):
8:34 No overload matches this call.
The last overload gave the following error.
Argument of type '{}' is not assignable to parameter of type 'ComponentOptionsWithObjectProps<readonly string[] | Readonly<ComponentObjectPropsOptions<Data>>, unknown, unknown, {}, {}, Record<string, any>, ComponentOptionsMixin, ComponentOptionsMixin, string, Readonly<...> | Readonly<...>>'.
Property 'props' is missing in type '{}' but required in type '{ props: readonly string[] | Readonly<ComponentObjectPropsOptions<Data>>; }'.
6 | it("renders props.msg when passed", () => {
7 | const msg = "new message";
> 8 | const wrapper = shallowMount(HelloWorld, {
| ^
9 | props: { msg }
10 | });
11 | expect(wrapper.text()).to.include(msg); |
Can you share your test? Code-base? Are you only the latest beta for Vue? I am on beta 16 and alpha 8 for Vue and VTU respectively. There is a template you could use here to repro: https://github.com/lmiller1990/vtu-next-demo. I can' see where you are using |
@lmiller1990 the repo URL is in my previous message. Here again https://github.com/rtbo/testvue3-ts I've started a template with |
With https://github.com/lmiller1990/vtu-next-demo I don't have compilation error. |
Weird one. One obvious problem is you are doing I'll keep playing around. I guess it is some conflicting type definitions somewhere... |
Just adding a data point:
|
I am getting this in your repo too, I cannot repro in my own template. Not sure why I wonder if we should write a cli-plugin for test-utils next and see if that helps with the dependency weirdness. |
Potential stupid solution: simplify the RouterStub definitions (no real reason it needs to be strongly typed with I will try this today. TS is hard sometimes! |
Yes, this is basically the same root issue than #143 Right now you can:
module.exports = {
chainWebpack: config => {
// fork-ts-checker is sadly ignoring the Vue shim
// and throws incorrect errors
// we disable it as it is just a nice to have to speed up the build
config.plugins.delete('fork-ts-checker');
config.module
.rule('ts')
.use('ts-loader')
.tap(options => {
return { ...options, transpileOnly: false };
});
}
}; I haven't found the root reason why we need this, but hopefully I will. @lmiller1990 Yes, just having bad typings in VTU breaks |
Is there something we can do on our end? Adding that transpileOnly mod is pretty hard, many people will not know/want to extend their webpack config. Ideally you should just add vue-jest, vue-test-utils and be ready to rock and roll. We should add this to the README, perhaps. Or maybe we need a vue-test-utils-next cli plugin. |
@lmiller1990 I think we should be able to fix the first issue on VTU side. For the second one, I spent some time debugging it and came with this workaround, but I was hoping to discuss it with @sodatea . This might be a good occasion to have his opinion on the matter 🙂 (cc @sodatea ) |
I've also encountered this issue when working on Yeah, while there are type issues to fix in the test-utils,
After a second thought, I think it may not be the best option. If we have a dedicate tsconfig for test, what about production mode? Shall we have 3 different configs or just reuse one for both test and production? Both options don't feel right to me. Actually, after reading jaredpalmer/tsdx#529, I'm inclined to have |
Anyway, we should really fix the issue in VTU at one point. For the separate tsconfig: you don't need a third one for production. The point of having a |
Oh, that makes sense.
🤔 Hmm, We can discuss it in a separate thread. But as far as I can tell, the community seems more inclined to not recommend |
I don't understand why we need a workaround. What is the actual problem? Why does exporting a component with |
@lmiller1990 The bug here is that the published version of Maybe due to the cache from A clean build of this repo fixes this issue. |
I wonder if the cache was the problem - we have definitely done a release since beta.15. I will do another release with the latest, cleaned build in the next day or so! Thanks. I guess we should move to beta now (I don't see any blockers) after this fix is released. |
See this file: https://unpkg.com/browse/@vue/[email protected]/dist/components/RouterLinkStub.d.ts If it's correctly built from vue >= 3.0.0-beta.15, there should be something like |
Now that @lmiller1990 released |
Great! |
I have installed a VueJS 3 app and upgraded test-utils to the latest alpha. An attempt to serve the app locally returns this error:
It seems the interface
ComponentOptionsBase
is incorrectly specified orRouterLink.d.ts
has the wrong number of arguments.Is this expected behaviour or is this an issue? Is there a workaround?
The text was updated successfully, but these errors were encountered: