Skip to content

Commit 84abd11

Browse files
authored
types(router): added router array type for Array RouteConfig (#4805)
* types(router): added router array type for Array RouteConfig * Update index.js * Update index.js
1 parent 0380f22 commit 84abd11

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/@vue/cli-plugin-router/generator/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ module.exports = (api, options = {}) => {
1010

1111
api.render('./template', {
1212
historyMode: options.historyMode,
13-
doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript')
13+
doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript'),
14+
hasTypeScript: api.hasPlugin('typescript')
1415
})
1516

1617
if (api.invoking) {

packages/@vue/cli-plugin-router/generator/template/src/router/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import Vue from 'vue'
2+
<%_ if (hasTypeScript) { _%>
3+
import VueRouter, { RouteConfig } from 'vue-router'
4+
<%_ } else { _%>
25
import VueRouter from 'vue-router'
6+
<%_ } _%>
37
import Home from '../views/Home.vue'
48

59
Vue.use(VueRouter)
610

7-
const routes = [
11+
<%_ if (hasTypeScript) { _%>
12+
const routes: Array<RouteConfig> = [
13+
<%_ } else { _%>
14+
const routes = [
15+
<%_ } _%>
816
{
917
path: '/',
1018
name: 'Home',

0 commit comments

Comments
 (0)