Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] No types in module for typescript #70

Open
sebastien-abbal opened this issue Dec 15, 2023 · 1 comment
Open

[BUG] No types in module for typescript #70

sebastien-abbal opened this issue Dec 15, 2023 · 1 comment
Milestone

Comments

@sebastien-abbal
Copy link

Hello ! :)

I am importing the types from the module (for typescript), i have all any by default.
And when i am going to the node_modules/next-export-i18n, i don't have any types accessible from the index.d.ts.

// node_modules/next-export-i18n/index.d.ts

import useLanguageQuery from "./hooks/use-language-query";
import useSelectedLanguage from "./hooks/use-selected-language";
import useLanguageSwitcherIsActive from "./hooks/use-language-switcher-is-active";
import { useTranslation } from "./hooks/use-translation";
import LanguageSwitcher from "./components/language-switcher";
import LinkWithLocale from "./components/link-with-locale";
import i18n from "./index.js";
export { useLanguageQuery, useSelectedLanguage, useLanguageSwitcherIsActive, useTranslation, LanguageSwitcher, LinkWithLocale, };
export default i18n;

But the module structure is:

# node_modules/next-export-i18n

next-export-i18n
├── node_modules/.bin
│   ├── mustache
│   └── next
├── index.d.ts
├── index.js
├── LICENSE
├── package.json
└── README.md

So there is no ./hooks folder or ./components folder available.
Do you have any idea ? or i am doing something bad ?

Regards,

@martinkr martinkr added this to the 3.1.0 milestone Dec 16, 2023
@danghieuliem
Copy link

danghieuliem commented Jan 15, 2024

my solution:
creat file i18n.d.ts in folder @type

import { LinkProps } from 'next/link'
declare module 'next-export-i18n' {
  export function useLanguageSwitcherIsActive(): { isActive: boolean }
  export function useTranslation(): { t: (key: string) => string }

  export function useSelectedLanguage(): {
    lang: string
    setLang: (key: 'en' | 'vi') => void
  }

  export function LanguageSwitcher(props: {
    lang: string
    children?: ReactNode
  }): React.ReactElement

  export function LinkWithLocale(
    props: LinkProps & {
      children: ReactNode
    },
  ): React.ReactElement
}

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

No branches or pull requests

3 participants