diff --git a/.electron-vue/webpack.renderer.config.js b/.electron-vue/webpack.renderer.config.js index 263b6990..304b3c72 100644 --- a/.electron-vue/webpack.renderer.config.js +++ b/.electron-vue/webpack.renderer.config.js @@ -65,7 +65,6 @@ let rendererConfig = { { test: /\.ts$/, exclude: /node_modules/, - // include: path.join(__dirname , '../node_modules/vue-awesome'), use: { loader: 'ts-loader', options: { @@ -157,11 +156,12 @@ let rendererConfig = { }, resolve: { alias: { + // Same as tsconfig.json '@': path.join(__dirname, '../src/renderer'), '~': path.join(__dirname, '../'), 'vue$': 'vue/dist/vue.esm.js' }, - extensions: ['.js', '.vue', '.json', '.css', '.node', '.ts'] + extensions: ['.ts', '.js', '.vue', '.json', '.css', '.node'] }, target: 'electron-renderer' } diff --git a/package-lock.json b/package-lock.json index 11af4772..7aff7e4b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -560,6 +560,12 @@ "@types/node": "11.11.4" } }, + "@types/i18next": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/@types/i18next/-/i18next-12.1.0.tgz", + "integrity": "sha512-qLyqTkp3ZKHsSoX8CNVYcTyTkxlm0aRCUpaUVetgkSlSpiNCdWryOgaYwgbO04tJIfLgBXPcy0tJ3Nl/RagllA==", + "dev": true + }, "@types/node": { "version": "11.11.4", "resolved": "https://registry.npmjs.org/@types/node/-/node-11.11.4.tgz", diff --git a/package.json b/package.json index 3cecd272..81257886 100644 --- a/package.json +++ b/package.json @@ -152,6 +152,7 @@ }, "devDependencies": { "@mapbox/stylelint-processor-arbitrary-tags": "^0.2.0", + "@types/i18next": "^12.1.0", "@types/node": "^11.11.4", "@vue/test-utils": "^1.0.0-beta.28", "ajv": "^6.6.1", diff --git a/src/config/i18n.js b/src/config/i18n.ts similarity index 69% rename from src/config/i18n.js rename to src/config/i18n.ts index 2888d6de..a3b2448a 100644 --- a/src/config/i18n.js +++ b/src/config/i18n.ts @@ -1,8 +1,9 @@ -import path from 'path' -import i18next from 'i18next' -import Backend from 'i18next-sync-fs-backend' +import * as path from 'path' +import * as i18next from 'i18next' +import * as Backend from 'i18next-sync-fs-backend' +import { InitOptions } from 'i18next' -const options = { +const options: InitOptions = { initImmediate: false, lng: 'en', backend: { diff --git a/src/renderer/main.ts b/src/renderer/main.ts index 27e67683..7d12f086 100644 --- a/src/renderer/main.ts +++ b/src/renderer/main.ts @@ -36,7 +36,7 @@ sync(store, router) if (!process.env.IS_WEB) Vue.use(require('vue-electron')) Vue.config.productionTip = false -const i18n = new VueI18Next(i18next) +const i18n: VueI18Next = new VueI18Next(i18next) /* eslint-disable no-new */ new Vue({ diff --git a/tsconfig.json b/tsconfig.json index 0c480004..d171ab5e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -37,8 +37,11 @@ /* Module Resolution Options */ "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ + "paths": { + "@*": ["src/renderer*"], + "~*": ["./*"] + }, // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ "typeRoots": ["./types"], /* List of folders to include type definitions from. */ // "types": [], /* Type declaration files to be included in compilation. */ diff --git a/types/i18next-sync-fs-backend.d.ts b/types/i18next-sync-fs-backend.d.ts new file mode 100644 index 00000000..d2c7b362 --- /dev/null +++ b/types/i18next-sync-fs-backend.d.ts @@ -0,0 +1 @@ +declare module 'i18next-sync-fs-backend'