Skip to content

better typescript support #243

Description

@schiller-manuel

Currently @shopify/i18next-shopify does not have dedicated typescript support.
This results in typescript errors e.g. when using its custom pluralization with nested keys and using a declaration file as explained in https://www.i18next.com/overview/typescript#create-a-declaration-file

Example

i18n resource

"variants": {
      "one": "{{count}} variant",
      "other": "{{count}} variants"
}

usage

 <Text variant="bodySm" as="p" tone="subdued">
    {t('variants', {
      count: 1,
    })}
</Text>

typescript error

Argument of type '["variants", { count: number; }]' is not assignable to parameter of type '[key: "change" | "select" | "variants.one" | "variants.other" | TemplateStringsArray | ("change" | "select" | "variants.one" | "variants.other" | TemplateStringsArray)[], options?: ({ ...; } & InterpolationMap<...>) | undefined] | [key: ...] | [key: ...]'.
  Type '["variants", { count: number; }]' is not assignable to type '[key: string | string[], defaultValue: string, options?: ({ count: number; } & $Dictionary) | undefined]'.
    Type at position 1 in source is not compatible with type at position 1 in target.
      Type '{ count: number; }' is not assignable to type 'string'.ts(2345)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions