MaximVanhove / vue-router-back-button

Add a back button to your application
MIT License
66 stars 9 forks source link

No typescript support #4

Closed jvik closed 5 years ago

jvik commented 5 years ago

Any plans on implementing typescript types for this package?

MaximVanhove commented 5 years ago

Shouldn't plain javascript be supported by typescript? What issues are you having?

jvik commented 5 years ago
Could not find a declaration file for module 'vue-router-back-button'. '/Users/jvik/project/node_modules/vue-router-back-button/dist/index.js' implicitly has an 'any' type.
  Try `npm install @types/vue-router-back-button` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-router-back-button';`

TS Errors like this when importing

MaximVanhove commented 5 years ago

You can use the follow syntax for now:

import Vue from 'vue';
import Router from 'vue-router';

const VueRouterBackButton = require('vue-router-back-button');

Vue.use(Router);
Vue.use(VueRouterBackButton.routerHistory);

const router = new Router({
    routes: [
        //
    ],
});

router.afterEach(VueRouterBackButton.writeHistory);

export default router;