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

Broken types in useTransContext #36

@thearturca

Description

@thearturca

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? 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions