Add typescript compatibility

This commit is contained in:
Sebastien Chopin 2017-05-05 14:07:54 +02:00
parent 8a620dcc30
commit 01b02a9010
2 changed files with 5 additions and 5 deletions

View File

@ -1,5 +1,5 @@
<% if (middleware) { %>
let files = require.context('~/middleware', false, /^\.\/.*\.js$/)
let files = require.context('~/middleware', false, /^\.\/.*\.(js|ts)$/)
let filenames = files.keys()
function getModule (filename) {
@ -12,7 +12,7 @@ let middleware = {}
// Generate the middleware
for (let filename of filenames) {
let name = filename.replace(/^\.\//, '').replace(/\.js$/, '')
let name = filename.replace(/^\.\//, '').replace(/\.(js|ts)$/, '')
middleware[name] = getModule(filename)
}

View File

@ -2,7 +2,7 @@ import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
let files = require.context('~/store', true, /^\.\/.*\.js$/)
let files = require.context('~/store', true, /^\.\/.*\.(js|ts)$/)
let filenames = files.keys()
function getModule (filename) {
@ -30,7 +30,7 @@ let storeData = {}
if (filenames.indexOf('./index.js') !== -1) {
let mainModule = getModule('./index.js')
if (mainModule.commit) {
console.error('[nuxt.js] store/index.js should export raw store options instead of an instance.')
console.error('[nuxt.js] store/index should export raw store options instead of an instance.')
} else {
if (mainModule.state && typeof mainModule.state !== 'function') {
console.error('[nuxt.js] store state should be a function.')
@ -43,7 +43,7 @@ if (filenames.indexOf('./index.js') !== -1) {
if (store == null) {
storeData.modules = storeData.modules || {}
for (let filename of filenames) {
let name = filename.replace(/^\.\//, '').replace(/\.js$/, '')
let name = filename.replace(/^\.\//, '').replace(/\.(js|ts)$/, '')
if (name === 'index') continue
let namePath = name.split(/\//)