vue-i18n
vue-i18n copied to clipboard
Typescript error with custom composable after switching to pnpm
trafficstars
Reporting a bug?
I have this composable that stores local messages:
import { type I18nScope, useI18n } from 'vue-i18n'
interface UseI18nSchema<T extends string = string> {
message: Record<T, string | object>
}
type UseI18nLocale = (typeof localeOptions)[number]['id']
export const useTranslations = (props?: { scope?: I18nScope }) => {
const { scope = 'global' } = props || {}
const { t } = useI18n<UseI18nSchema, UseI18nLocale>({
useScope: scope,
messages: {
en: {
test: 'Test'
},
ru: {
test: 'Тест'
},
uz: {
test: 'Test'
}
}
})
return { t }
}
After I switched to pnpm, I started getting this error:
The inferred type of 'useTranslations' cannot be named without a reference to '.pnpm/@[email protected]/node_modules/@intlify/core-base'. This is likely not portable. A type annotation is necessary.ts(2742)

Can someone explain why? Is it because I switched to pnpm or is there a problem with vue-i18n library itself?
Expected behavior
I expect not to have this error
Reproduction
https://github.com/Sardor01/vue-i18n-reproduction
System Info
System:
OS: Linux 6.0 Pop!_OS 22.04 LTS
CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
Memory: 3.34 GB / 11.56 GB
Container: Yes
Shell: 5.8.1 - /usr/bin/zsh
Binaries:
Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.13.0/bin/yarn
npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
pnpm: 7.26.3 - ~/.nvm/versions/node/v18.13.0/bin/pnpm
Browsers:
Chrome: 109.0.5414.119
Firefox: 109.0
npmPackages:
@intlify/unplugin-vue-i18n: ^0.8.1 => 0.8.1
@vitejs/plugin-vue: ^4.0.0 => 4.0.0
@vue/eslint-config-prettier: ^7.0.0 => 7.0.0
@vue/eslint-config-typescript: ^11.0.2 => 11.0.2
@vue/test-utils: ^2.2.8 => 2.2.8
@vue/tsconfig: ^0.1.3 => 0.1.3
vite: ^4.0.4 => 4.0.4
vitest: ^0.28.3 => 0.28.3
vue: ^3.2.45 => 3.2.45
vue-i18n: ^9.2.2 => 9.2.2
vue-router: ^4.1.6 => 4.1.6
vue-tsc: ^1.0.8 => 1.0.24
vue3-apexcharts: ^1.4.1 => 1.4.1
Screenshot
No response
Additional context
No response
Validations
- [X] Read the Contributing Guidelines
- [X] Read the Documentation
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a GitHub Discussions