vue-i18n icon indicating copy to clipboard operation
vue-i18n copied to clipboard

Upgrade to typescript5 and ts-config 0.3.*, type loss problem

Open laterdayi opened this issue 2 years ago • 3 comments
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

laterdayi avatar May 06 '23 09:05 laterdayi

I've got the same problem after upgrading typescript5 and ts-config 0.3.*

skormel avatar May 08 '23 11:05 skormel

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.

nozomuikuta avatar May 11 '23 16:05 nozomuikuta

Ah, I found this issue is well-explained in #1327. You might want to check the conversation.

nozomuikuta avatar May 11 '23 16:05 nozomuikuta