Skip to content

Commit

Permalink
types(router): added router array type for Array RouteConfig (#4805)
Browse files Browse the repository at this point in the history
* types(router): added router array type for Array RouteConfig

* Update index.js

* Update index.js
  • Loading branch information
manuelojeda committed Feb 28, 2020
1 parent 0380f22 commit 84abd11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/@vue/cli-plugin-router/generator/index.js
Expand Up @@ -10,7 +10,8 @@ module.exports = (api, options = {}) => {

api.render('./template', {
historyMode: options.historyMode,
doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript')
doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript'),
hasTypeScript: api.hasPlugin('typescript')
})

if (api.invoking) {
Expand Down
@@ -1,10 +1,18 @@
import Vue from 'vue'
<%_ if (hasTypeScript) { _%>
import VueRouter, { RouteConfig } from 'vue-router'
<%_ } else { _%>
import VueRouter from 'vue-router'
<%_ } _%>
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
<%_ if (hasTypeScript) { _%>
const routes: Array<RouteConfig> = [
<%_ } else { _%>
const routes = [
<%_ } _%>
{
path: '/',
name: 'Home',
Expand Down

0 comments on commit 84abd11

Please sign in to comment.