I have created a component in one project and now I want to make it accessible for use in another project. This is how I am currently exposing it:
import ToastNotification from '../ToastNotification'; import Api from './api'; const VueToast = (Vue, options = {}) => { const methods = Api(Vue, options); Vue.$toast = methods; Vue.prototype.$toast = methods; }; ToastNotification.install = VueToast; export default ToastNotification;
In my index.js file I declare :
import VueToast from './toast/js/index'; Vue.use(VueToast);
However, when I npm install this project as a library in another project, the line this.$toast('message') is not recognized and shows an error, stating "Property '$toast' does not exist on type ''".
Interestingly, I was able to use 'this.$toast('')' within the original project, but facing issues when trying to do so in a different project. The component is built using Vue.js and JavaScript and I am attempting to integrate it into a TypeScript-supported Vue.js project.
I have also tried declaring it in the main.ts file of my project, but the issue persists:
import VueToast from'/src/components/toast/js/index';
Vue.use(VueToast);
Can you suggest what may be missing or needs to be declared differently?