Vue 3 typecheck fails on `:navigation` because it doesn't recognize the type
See original GitHub issueCheck that this is really a bug
- I confirm
Reproduction link
…
Bug description
<template>
<swiper
slides-per-view="auto"
:space-between="40"
:navigation="{
nextEl: `.swiper-next-${id}`,
prevEl: `.swiper-prev-${id}`
}"
:modules="swiperModules"
>
</template>
This component causes the following typescript error when ran with vue-tsc
Type '{ nextEl: string; prevEl: string; }' is not assignable to type 'undefined'.
55 :navigation="{
Something must be wrong with how the :navigation
type is set. Other properties are recognized with no issues.
Expected Behavior
There should not be a typescript error since the data matches the expected type, and type unknown
should not be the type of the prop.
Actual Behavior
With the prop having type unknown
it is impossible to match any values with it when you have a strict ts implementation.
Swiper version
8.1.4
Platform/Target and Browser Versions
Node 16
Validations
- Follow our Code of Conduct
- Read the docs.
- Check that there isn’t already an issue that request the same feature to avoid creating a duplicate.
- Make sure this is a Swiper issue and not a framework-specific issue
Would you like to open a PR for this bug?
- I’m willing to open a PR
Issue Analytics
- State:
- Created a year ago
- Comments:5
Top Results From Across the Web
What causes the type check failed for prop error in this Vue 3 ...
As can be seen above, I have explicitly set dataIsLoaded to a boolean. Yet, in the console, I get the error: Invalid prop:...
Read more >Options: State - Vue.js
In development mode, Vue will check if a prop's value matches the declared type, and will throw a warning if it doesn't. See...
Read more >TypeScript | WebStorm Documentation - JetBrains
Here you can view problem descriptions, apply quick-fixes, navigate to the fragments in the source code where errors occurred, as well as fix ......
Read more >Configuring Vitest
Vitest doesn't do static analysis, and cannot fail before your running code, so you will most likely see this error when running tests:....
Read more >TypeScript support in Svelte - Learn web development
Not true static typing: Types are only checked at compile time, and they are removed from the generated code. Steep learning curve: Even...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@stijn-gravity thanks for the help! I also found another way: I created a file named
shim-vue.d.ts
and placed in the root directory of the project with the following code:Thanks! IT WORKS!