nativescript-vue / nativescript-vue-navigator

A simple router for NativeScript-Vue, built on top of $navigateTo to simplify routing from within components
MIT License
98 stars 10 forks source link

Could not find a declaration file for module 'nativescript-vue-navigator' #20

Open hgc2002 opened 4 years ago

hgc2002 commented 4 years ago

I just install nativescript-vue-navigator to test it with 3 very basic pages (just labels and buttons on them) and this happened (also it crashed on ios).

Then I saw this message in the editor (vscode):

Could not find a declaration file for module 'nativescript-vue-navigator'. '/Users/hgc/aaa/proyectos/polimanual-nsvue/node_modules/nativescript-vue-navigator/index.js' implicitly has an 'any' type. Trynpm install @types/nativescript-vue-navigatorif it exists or add a new declaration (.d.ts) file containingdeclare module 'nativescript-vue-navigator';ts(7016)

Apparently my project believes it has TypeScript somewhere, that is little strange because I simply download it from NSPlayground (yes, the web!, and starting the tutorial from scratch with HelloWorld!).

I was playing with other projects before to learn TypeScript but I don't know how all got messed to this point.

PixsaOJ commented 1 year ago

In declarations: declare module 'nativescript-vue-navigator'

In component: $navigator: any;

dcamargon commented 11 months ago

In case this help anyone, here is what worked for me

I wonder how Vuex was able to have the store property configured, so found the following code here https://github.com/vuejs/vuex/blob/v3.6.2/types/vue.d.ts

In the types folder, I created a modules.d.ts file with the following content

import Vue, { ComponentOptions } from "vue";

declare module "nativescript-vue-navigator";

declare module "vue/types/options" {
  interface ComponentOptions<V extends Vue> {
    navigator?: any;
  }
}

declare module "vue/types/vue" {
  interface Vue {
    $navigator: any;
  }
}