question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TFunction is declared locally but not exported

See original GitHub issue

🐛 Bug Report

In version < 12.0.0 the react-i18next lib exported a TFunction.

To Reproduce

Import the TFunction in version 12.0.0

import { TFunction } from "react-i18next";

Expected behavior

I would like to type a parameter as a TFunction which was imported from react-i18next

import { TFunction } from "react-i18next";

type Generator = (
  client: Client,
  t: TFunction<"common">,
) => Promise<{ title: string; link: string }>;

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
albohlabscommented, Oct 24, 2022

Awesome. It works. Many thanks for your great work. 🎖️

0reactions
pedrodurekcommented, Oct 25, 2022

Hey @albohlabs, we just moved the types to i18next. In order to have i18next and react-i18next fully type-safe, just follow the instructions here https://www.i18next.com/overview/typescript. In short, you just need to change the declare module "react-i18next" line to declare module "i18next"

Read more comments on GitHub >

github_iconTop Results From Across the Web

module declares component locally, but it is not exported
You need not import AddtimeComponent in the main module. You have to export it in SharedModule like below.
Read more >
Module '"react-i18next"' declares 'TFunction' locally, but it is ...
When importing the TFunction, it has worked previously as it's been exported: import { TFunction } from 'react-i18next';. However, that's no longer the...
Read more >
Documentation - Modules - TypeScript
Any declaration (such as a variable, function, class, type alias, or interface) ... A re-export does not import it locally, or introduce a...
Read more >
Testing Non-Exported Functions in JavaScript - Samantha Ming
To test exported function, you can simply import it. But what about non-exported functions? Well that's easy too, thanks to Rewire!
Read more >
Chapter 5 Modules - Haskell.org
If the export list is omitted, all values, types and classes defined in the module are exported, but not those that are imported....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found