@resibe
19-летний пушистик

Как установить vue-i18n + typescript?

Здравствуйте, я создал пустой проект vue 3 с TypeScript и запустил vue add i18n
После чего получаю
This dependency was not found:
* vue-i18n in ./src/i18n.ts
To install it, you can run: npm install --save vue-i18n

После выполнения yarn add vue-i18n
Получаю
This dependency was not found:

* vue-i18n in ./src/i18n.ts

To install it, you can run: npm install --save vue-i18n
ERROR in src/i18n.ts:1:10
TS2614: Module '"../node_modules/vue-i18n/types"' has no exported member 'createI18n'. Did you mean to use 'import createI18n from "../node_modules/vue-i18n/types"' instead?
  > 1 | import { createI18n, LocaleMessages, VueMessageType } from "vue-i18n";
      |          ^^^^^^^^^^
    2 |
    3 | /**
    4 |  * Load locale messages

ERROR in src/i18n.ts:1:38
TS2614: Module '"../node_modules/vue-i18n/types"' has no exported member 'VueMessageType'. Did you mean to use 'import VueMessageType from "../node_modules/vue-i18n/types"' instead?
  > 1 | import { createI18n, LocaleMessages, VueMessageType } from "vue-i18n";
      |                                      ^^^^^^^^^^^^^^
    2 |
    3 | /**
    4 |  * Load locale messages

ERROR in src/i18n.ts:9:32
TS2315: Type 'LocaleMessages' is not generic.
     7 |  * See: https://github.com/intlify/vue-i18n-loader#rocket-i18n-resource-pre-compilation
     8 |  */
  >  9 | function loadLocaleMessages(): LocaleMessages<VueMessageType> {
       |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    10 |   const locales = require.context(
    11 |     "./locales",
    12 |     true,

ERROR in src/i18n.ts:15:19
TS2315: Type 'LocaleMessages' is not generic.
    13 |     /[A-Za-z0-9-_,\s]+\.json$/i
    14 |   );
  > 15 |   const messages: LocaleMessages<VueMessageType> = {};
       |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    16 |   locales.keys().forEach((key) => {
    17 |     const matched = key.match(/([A-Za-z0-9-_]+)\./i);
    18 |     if (matched && matched.length > 1) {

Что я сделал не правильно, без TS все работает
Странно что сам модуль vscode видит
619192b15efbb900151480.png
  • Вопрос задан
  • 612 просмотров
Решения вопроса 1
Aetae
@Aetae Куратор тега TypeScript
Тлен
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы