Skip to content

vue-i18n-bridge: Type error for the i18n instance specified for new Vue. #695

@kazupon

Description

@kazupon

Reporting a bug?

Vue CLI build error:

ERROR in /Users/kazuya.kawaguchi/Projects/tmp/vue-i18n-bridge-dog/src/main.ts(12,3):
12:3 No overload matches this call.
  Overload 1 of 3, '(options?: ThisTypedComponentOptionsWithArrayProps<Vue, object, object, object, never> | undefined): CombinedVueInstance<Vue, object, object, object, Record<...>>', gave the following error.
    Type 'I18n<LocaleMessages, {}, {}, any, true>' has no properties in common with type '{ messages?: LocaleMessages | undefined; dateTimeFormats?: DateTimeFormats | undefined; numberFormats?: NumberFormats | undefined; sharedMessages?: LocaleMessages | undefined; }'.
  Overload 2 of 3, '(options?: ThisTypedComponentOptionsWithRecordProps<Vue, object, object, object, object> | undefined): CombinedVueInstance<Vue, object, object, object, Record<...>>', gave the following error.
    Type 'I18n<LocaleMessages, {}, {}, any, true>' has no properties in common with type '{ messages?: LocaleMessages | undefined; dateTimeFormats?: DateTimeFormats | undefined; numberFormats?: NumberFormats | undefined; sharedMessages?: LocaleMessages | undefined; }'.
  Overload 3 of 3, '(options?: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<Record<string, any>>, Record<...>> | undefined): CombinedVueInstance<...>', gave the following error.
    Type 'I18n<LocaleMessages, {}, {}, any, true>' has no properties in common with type '{ messages?: LocaleMessages | undefined; dateTimeFormats?: DateTimeFormats | undefined; numberFormats?: NumberFormats | undefined; sharedMessages?: LocaleMessages | undefined; }'.
    10 |
    11 | new Vue({
  > 12 |   i18n,
       |   ^
    13 |   render: h => h(App)
    14 | }).$mount('#app')
    15 |

 ERROR  Build failed with errors.

Expected behavior

The i18n instance returned by createI18n must pass the Vue constructor type.

Reproduction

I'm vue-i18n author, reproduction code is in my PC

System Info

System:
    OS: macOS 10.15.7
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 19.40 GB / 64.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 16.9.1 - ~/bin/.nvm/versions/node/v16.9.1/bin/node
    Yarn: 1.22.11 - ~/bin/.nvm/versions/node/v16.9.1/bin/yarn
    npm: 7.21.1 - ~/bin/.nvm/versions/node/v16.9.1/bin/npm
  Browsers:
    Chrome: 93.0.4577.82
    Safari: 15.0
  npmPackages:
    vue: ^2.6.11 => 2.6.14
    vue-i18n: ^8.26.1 => 8.26.1

Screenshot

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions