-
Notifications
You must be signed in to change notification settings - Fork 32
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
TS error: Implicit conversion of a 'symbol' to a 'string' will fail at runtime #80
Comments
Hi! How would you suggest to fix this bug? Thanks. |
Thanks for looking! I’m on holiday for a week but can provide a reproduction when I’m back. I haven’t taken a proper look at the code, but I imagine maybe the functions involved unintentionally accept |
@baffalop any demo app with as minimal code as possible that can make this error to appear is sufficient. A better way is to create a unit test to mock a minimal app with a demo state to retrieve the expected result you want it to have. |
@davidmeirlevy Here is a reproduction with a single unit test which fails because of the type error: (Run |
I came back to this to see if I could contribute a PR, but now I realise that it's a much more mysterious issue than I thought. I expected to be able to reproduce it just by bumping the typescript version, but nope—and quite reasonably, because the export declare type KnownKeys<T> = Exclude<KnownKeysWithAllPrimitiveTypes<T>, symbol> And the My only guess at this point is that |
Update: I just realised that the export declare type KnownKeys<T> = {
[K in keyof T]: string extends K
? (T extends any ? any : never)
: number extends K
? never
: K
} extends {
[_ in keyof T]: infer U
}
? U
: never; This is the old type which as part of 56a2acc was refactored to I have I'm so confused. It seems the fix is out there but just does not get installed by npm. I don't have experience with library authorship so I don't know how npm resolves versions. Can you shed any light on this? |
I was able to bypass the issue by installing the fork @wisdomgarden/vuex-composition-helpers which has a version I think this issue might boil down to: the code published under versions 2.0.2 and 2.0.3 does not reflect the latest src. |
I have the same issue. Installing fork version as @baffalop suggested seems to resolve the problem. |
@radek-furmanski worth noting that another way to bypass the typescript errors in Jest is to use the dist js version of moduleNameMapper: {
'vuex-composition-helpers': '<rootDir>/node_modules/vuex-composition-helpers/dist/index.js'
} This is what I went with in the end rather than using the fork. |
I am upgrading a codebase to Vue 3, so have upgraded
vuex-composition-helpers
to2.0.3
.When running unit tests for components using this library, I get a typescript error:
Because the library is uncompiled typescript, I have to include it in my Jest transform, with:
This means that the library is typechecked as part of my unit tests.
Versions
vuex-composition-helpers: 2.0.3
typescript: 5.2.2
jest: 29.7.0
ts-jest: 29.1.1
@vue/vue3-jest: 29.2.6
The text was updated successfully, but these errors were encountered: