Merkushin-AY / vue-3-breadcrumbs

This plugin adds breadcrumbs to your project based on vue 3 or nuxt 3. It provides easy and variable setup with Vue Router. Also, it includes the small component.
MIT License
6 stars 0 forks source link

Unable to use with TypeScript #1

Open baracuda69 opened 2 years ago

baracuda69 commented 2 years ago

My project is in TypeScript, so the entry-point is main.ts (not main.js).

When trying to import breadcrumbs from 'vue-3-breadcrumbs'; I get an error: Could not find a declaration file for module 'vue-3-breadcrumbs'. '/node_modules/vue-3-breadcrumbs/dist/cjs/breadcrumbs.js' implicitly has an 'any' type. Try npm i --save-dev @types/vue-3-breadcrumbs if it exists or add a new declaration (.d.ts) file containing declare module 'vue-3-breadcrumbs';

I have worked-around the issue by creating

/node-modules/vue-3-breadcrumbs/dist/cjs/breadcrumbs.d.ts file with the following content:

/ eslint-disable / declare module "vue-3-breadcrumbs" { import type { DefineComponent } from 'vue' const component: DefineComponent<{}, {}, any> export default component }

This should be pre-bundled :)

Cheers Adam

baracuda69 commented 2 years ago

Even with adding said ts-file, it is not possible to do app..use(breadcrumbs)

Argument of type 'DefineComponent<{}, {}, any, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, ... 4 more ..., {}>' is not assignable to parameter of type 'Plugin_2'. Type 'DefineComponent<{}, {}, any, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, ... 4 more ..., {}>' is not assignable to type '{ install: PluginInstallFunction; }'.ts(2345)

Merkushin-AY commented 2 years ago

Hello, Adam

Thank you for the comments. In future versions i will try to provide types. But for now you can create vendor.d.ts file near main.ts and add there declare module 'vue-3-breadcrumbs'