D
D
Danya Kozlovskiy2021-01-20 16:12:35
typescript
Danya Kozlovskiy, 2021-01-20 16:12:35

Can't find ts module. vue?

Hello, there was an error about types in TS:

property '$error' does not exist on type 'CombinedVueInstance<Vue, { email: string; password: string; }, { onSubmit(): void; }, unknown, Readonly<Record

, it seems to no longer swear, but for some reason it cannot find the module, although the error about types has disappeared. And I will be very grateful if you send me some articles, guides, etc. about using ts together with vue, where everything is written in detail about everything (documentation is not enough).

Mistake:
Failed to compile.

./src/main.ts
Module not found: Error: Can't resolve './token-service' in 'D:\__my_prog\vue\crm\src'


token-service.d.ts:
import Vue from 'vue'
import TokenService from '../path/to/token-service'

declare module 'vue/types/vue' {
  interface Vue {
    $message(html: string) : any 
    $error(html: string) : any 
  }
}


message.plugin.ts:
import M from 'materialize-css'

export default {
  install(Vue, options) {
    Vue.prototype.$message = function (html: string): any {
      M.toast({html})
    }

    Vue.prototype.$error = function(html: string): any {
      M.toast({html: `[Ошибка]: ${html}`})
    }
  }
}


main.ts:
import Vue from "vue";
import Vuelidate from 'vuelidate'
import App from "./App.vue";
import "./registerServiceWorker";
import router from "./router";
import store from "./store";
import dateFilter from "./filters/date.filter";
import messagePlugin from "./utils/message.plugin"
import './token-service'


Vue.config.productionTip = false;

Vue.use(messagePlugin)
Vue.use(Vuelidate as any)
Vue.filter('date', dateFilter)

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question