vue-i18n
vue-i18n copied to clipboard
Upgrade to typescript5 and ts-config 0.3.*, type loss problem
trafficstars
Reporting a bug?
type “{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}> & Omit<Readonly<ExtractPropTypes<{}>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>; ... 10 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => ...”not found“$t”。ts(2339)
There are types at '/node_modules/vue-i18n/dist/vue-i18n.d.ts', but this result could not be resolved when respecting package.json "exports". The 'vue-i18n' library may need to update its package.json or typings.ts(7016)
Expected behavior
type “{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}> & Omit<Readonly<ExtractPropTypes<{}>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>; ... 10 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => ...”not found“$t”。ts(2339)
There are types at '/node_modules/vue-i18n/dist/vue-i18n.d.ts', but this result could not be resolved when respecting package.json "exports". The 'vue-i18n' library may need to update its package.json or typings.ts(7016)
Reproduction
type “{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}> & Omit<Readonly<ExtractPropTypes<{}>> & VNodeProps & AllowedComponentProps & ComponentCustomProps, never>; ... 10 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => ...”not found“$t”。ts(2339)
There are types at '/node_modules/vue-i18n/dist/vue-i18n.d.ts', but this result could not be resolved when respecting package.json "exports". The 'vue-i18n' library may need to update its package.json or typings.ts(7016)
System Info
windows
depends latest
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
I've got the same problem after upgrading typescript5 and ts-config 0.3.*
For vue-i18n v9.2.2 (latest stable) to work with TypeScript 5, its package.json should define types property like below:
{
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/vue-i18n.esm-bundler.js",
"types": "./dist/vue-i18n.d.ts" // <-- This is needed
},
},
},
}
At the moment, what we can do on user side is either of the following:
- "patch-package" in our project
- fork this repository and publish the fixed version until v9.2.3 is released
By the way, as far as I tested with vite-ts template, vue-18n v9.3.0 (currently beta) works with TypeScript 5 at least in terms of type definition import.
Ah, I found this issue is well-explained in #1327. You might want to check the conversation.