Skip to content

typescript 4.8 support #1198

@ameinhardt

Description

@ameinhardt

Reporting a bug?

With a simple vue 3 and vue-i18n (e.g. v9.2+) typescript (v4.8+) setup, hundreds of circular constraints and index errors are thrown when building (tsc -c)

node_modules/.pnpm/@[email protected]/node_modules/@intlify/core-base/dist/core-base.d.ts:791:51 - error TS2313: Type parameter 'Context' has a circular constraint.

791 export declare function translate<Context extends CoreContext<Message, Context['messages'], {}, {}>, Key extends string = string, ResourceKeys extends PickupKeys<Context['messages']> = PickupKeys<Context['messages']>, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, defaultMsg: string): MessageType<Message> | number;
                                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/.pnpm/@[email protected]/node_modules/@intlify/core-base/dist/core-base.d.ts:791:72 - error TS2536: Type '"messages"' cannot be used to index type 'Context'.

791 export declare function translate<Context extends CoreContext<Message, Context['messages'], {}, {}>, Key extends string = string, ResourceKeys extends PickupKeys<Context['messages']> = PickupKeys<Context['messages']>, Message = string>(context: Context, key: Key | ResourceKeys | number | MessageFunction<Message>, defaultMsg: string): MessageType<Message> | number;

This does not happen in <4.7.4.
As a workaround, it is possible to "skipLibCheck": true in tsconfig.json. (see https://github.com/vuejs/tsconfig/blob/main/tsconfig.json / vuejs/vue-cli#5688)

Expected behavior

without skipping typescript lib checks, it is possible to use vue-i18n with typescript 4.8+

Reproduction

https://github.com/ameinhardt/tsI18n

System Info

Binaries:
  Node: 16.15.0
  npm: 8.5.5
npmPackages:
  see package-lock.json in reproduction repo

Screenshot

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    typescript❗ p4-importantPriority 4: bugs that violate documented behavior, or significantly impact perf

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions