[BUG] No types in module for typescript
sebastien-abbal opened this issue · 1 comments
sebastien-abbal commented
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,
danghieuliem commented
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
}