In Typescript, This dependency was not found
See original GitHub issue我使用typescript语言开发Vue的应用,在加入此插件时出现了如下的错误,导致无法使用。 Error Info:
ERROR in /Users/wurining/Documents/WebStormPRO/ccw_personal/src/components/portal/PostList.vue
33:41 Could not find a declaration file for module 'vue-awesome-swiper'. '/Users/wurining/Documents/WebStormPRO/ccw_personal/node_modules/vue-awesome-swiper/dist/vue-awesome-swiper.js' implicitly has an 'any' type.
Try `npm install @types/vue-awesome-swiper` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-awesome-swiper';`
31 |
32 | import 'swiper/dist/css/swiper.css'
> 33 | import { swiper, swiperSlide } from 'vue-awesome-swiper'
| ^
34 |
35 | @Component({
36 | swiper,
ERROR in /Users/wurining/Documents/WebStormPRO/ccw_personal/src/components/portal/PostList.vue
36:9 Argument of type '{ swiper: any; swiperSlide: any; }' is not assignable to parameter of type 'VueClass<Vue>'.
Object literal may only specify known properties, and 'swiper' does not exist in type 'VueClass<Vue>'.
34 |
35 | @Component({
> 36 | swiper,
| ^
37 | swiperSlide
38 | })
39 | export default class PostList extends Vue {
Version: typescript 2.9.2
Time: 645ms
使用vue-awesome-swiper的vue组件
<template>
<div>
<swiper :options="swiperOption">
<swiper-slide>Slide 1</swiper-slide>
<swiper-slide>Slide 2</swiper-slide>
<swiper-slide>Slide 3</swiper-slide>
<swiper-slide>Slide 4</swiper-slide>
<swiper-slide>Slide 5</swiper-slide>
<swiper-slide>Slide 6</swiper-slide>
<swiper-slide>Slide 7</swiper-slide>
<swiper-slide>Slide 8</swiper-slide>
<swiper-slide>Slide 9</swiper-slide>
<swiper-slide>Slide 10</swiper-slide>
<div class="swiper-pagination" slot="pagination"></div>
</swiper>
</div>
</template>
<style lang="scss">
</style>
<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import 'swiper/dist/css/swiper.css'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
@Component({
swiper,
swiperSlide
})
export default class PostList extends Vue {
swiperOption: object = {
slidesPerView : 3,
slidesPerColumn: 2,
spaceBetween : 30,
pagination : {
el : ".swiper-pagination",
clickable: true
}
};
}
</script>
目前看来应该是没有添加typescript的d.ts
声明文件。可否会写d.ts的老师添加一个pr?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12
Top Results From Across the Web
This dependency was not found - TypeScript, Vue
I am new to TS and Vue. Getting following error when trying to do vue-cli-service serve: This dependency was not found: * @store ......
Read more >This dependency was not found when using typescript · Issue #4
I ran the command in example folder but I got an error. screenshot_5. However, The following tip does not work for me.
Read more >How to set up TypeScript
TypeScript is available as a package on the npm registry available as "typescript" ... Then you use a dependency manager like npm, yarn...
Read more >ts-node - npm
TypeScript execution and REPL for node.js, with source map and native ESM support. The latest documentation can also be found on our ...
Read more >module-not-found - Next.js
The module you're trying to import is not installed in your dependencies ... When importing a module from npm this module has to...
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 FreeTop 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
Top GitHub Comments
Create a file called
vue-awesome-swiper.d.ts
with the following:Add devDependency for
@types/swiper
to get the rest of the type definitions添加