nuxt-typed-router
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -27,3 +27,3 @@ import fs from 'fs'; | ||
} | ||
routesEnum.push(route.name); | ||
routesEnum.push(`'${route.name}'`); | ||
}; | ||
@@ -36,4 +36,3 @@ routes.map(recursiveTypedRoutes); | ||
`; | ||
const routesEnumsTemplate = ` | ||
export type RouteNames = ${routesEnum.join('|')}; | ||
const routesEnumsTemplate = `export type RouteNames = ${routesEnum.join('|')}; | ||
`; | ||
@@ -40,0 +39,0 @@ |
import Vue from 'vue'; | ||
Vue.prototype.$safeRouter = this.nuxt.router; | ||
Vue.prototype.$safeRoute = this.nuxt.route; | ||
export default (ctx, inject) => { | ||
inject('safeRouter', ctx.app.router); | ||
inject('safeRoute', ctx.route); | ||
}; |
{ | ||
"name": "nuxt-typed-router", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Provide autocompletion for pages route names generated by Nuxt router", | ||
@@ -5,0 +5,0 @@ "main": "lib/module.js", |
@@ -1,2 +0,4 @@ | ||
import { SafeVueRouter } from './vue'; | ||
import Vue from 'vue'; | ||
import { SafeVueRouter, SafeRoute } from './vue'; | ||
import './vue'; | ||
@@ -30,1 +32,14 @@ interface NuxtTypedRouterOptions { | ||
} | ||
declare module 'vue/types/vue' { | ||
interface Vue { | ||
$safeRouter: SafeVueRouter; | ||
$safeRoute: SafeRoute; | ||
} | ||
} | ||
declare module 'vuex/types/index' { | ||
interface Store<S> { | ||
$safeRouter: SafeVueRouter; | ||
} | ||
} |
import VueRouter, { Location, Route, RouteRecord } from 'vue-router'; | ||
import { RouteNames } from './__generated.ts'; | ||
import { RouteNames } from './__generated'; | ||
import { ErrorHandler } from 'vue-router/types/router'; | ||
import { ComponentOptions } from 'vue/types/umd'; | ||
import Vue, { AsyncComponent } from 'vue'; | ||
interface SafeVueRouter extends VueRouter { | ||
type Component = ComponentOptions<Vue> | typeof Vue | AsyncComponent; | ||
export interface SafeVueRouter extends VueRouter { | ||
push(location: SafeRawLocation): Promise<SafeRoute>; | ||
@@ -25,25 +30,12 @@ replace(location: SafeRawLocation): Promise<SafeRoute>; | ||
interface SafeLocation extends Location { | ||
export interface SafeLocation extends Location { | ||
name?: RouteNames; | ||
} | ||
interface SafeRoute extends Route { | ||
export interface SafeRoute extends Route { | ||
name?: RouteNames; | ||
} | ||
interface SafeRouteRecord extends RouteRecord { | ||
export interface SafeRouteRecord extends RouteRecord { | ||
name?: RouteNames; | ||
} | ||
declare module 'vue/types/vue' { | ||
interface Vue { | ||
$safeRouter: SafeVueRouter; | ||
$safeRoute: SafeRoute; | ||
} | ||
} | ||
declare module 'vuex/types/index' { | ||
interface Store<S> { | ||
$safeRouter: SafeVueRouter; | ||
} | ||
} |
6008
135