Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Broken types in useTransContext #36

Open
thearturca opened this issue Nov 24, 2023 · 1 comment
Open

Broken types in useTransContext #36

thearturca opened this issue Nov 24, 2023 · 1 comment

Comments

@thearturca
Copy link

HI! Using your library. I have types generation for my i18next to have autocompletion in LSP. And cant get right types for t function from useTransContext. I have 10 different namespaces and without autocompletion its a mess.
Your library have this type. Seems the problem is here.

export declare const useTransContext: () => [TFunction<"translation", undefined>, TransProviderActions];

Its defaults to "translation" namespaces. Also in my case I have default namespace named "menu".

If I change types to

export declare const useTransContext: () => [i18n["t"], TransProviderActions];

then I am getting expected behavior for t function.

I was trying to redeclare types for module but got error from TS

import "@monorepo/i18n-next-typegen/types"; // importing my types for i18n
import { TransProviderActions } from "@mbarzda/solid-i18next";
import { i18n } from "i18next";

declare module "@mbarzda/solid-i18next" {
      export const useTransContext: () => [i18n["t"], TransProviderActions];
}

Error

image

What I get:

image

What I expect:

image

My custom types file

import Resources from "./i18n.resources.js";

declare module "i18next" {
      // Extend CustomTypeOptions
      interface CustomTypeOptions {
            defaultNS: "menu",
            // custom resources type
            resources: Resources;
      }
}

Does your library work with custom types? 🙏

@thearturca
Copy link
Author

Also key prop in Trans component have type of string. Which expected to be type of first argument of t function. That is not necessary for me but also would by a QOL improvement 🙏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant