-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add ready/tReady type definitions #753
Conversation
Adds missing type definitions for the `ready` return value of the `useTranslation` hook and the `tReady` prop added by the `withTranslation` HOC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add usage example to test/typescript
to prevent regressions
@rosskevin do you mean something like the following in // Component that uses ready to wait until translations are loaded because useSuspense is set to false
function ComponentNotUsingSuspense() {
const { t, ready } = useTranslation();
return (
<div>
{ready && t('key1')}
</div>
);
}
// Class based component that uses tReady to wait until translations are loaded because useSuspense is set to false
class ClassComponentNotUsingSuspense extends React.Component<WithTranslation> {
render() {
const { t, tReady } = this.props;
return <h2>{tReady && t('title')}</h2>;
}
} If there's anything that you want worded or named differently let me know. |
@traverse you can add both of those, but be sure to exercise them (just add them inside a closure): function suspenseUsage() {
// components code here
// exercise components code
return (
<div>
<ComponentNotUsingSuspense />
<ClassComponentNotUsingSuspense />
</div>
)
} |
@rosskevin Ok will do, thanks! |
@traverse any update on this? |
@jamuhl sorry about not giving an update on this, I was quite pressed for time last week and was bedridden over the weekend 🤒. I'm going to be spending some time on this today. |
@rosskevin any idea why the CI build might be failing? The tests are running fine locally 🤔 |
@traverse - it seems bizarre. I have tracked down dtslint to be relying on I'm looking into why dtslint is on
|
Issue microsoft/dtslint#159 |
@traverse this all looks good locally, I agree. I tried several things, all with full rebuilds, all which succeed locally but only fail on travis. @jamuh I don't have much confidence in travis at this point. I checked and there are no caches configured so I'm not sure what else to do there. My assumption at this point is that any change in this repo (even non-ts) is going to fail on travis due to some environmental situation there. I'm happy to merge this without travis success but worried that we will see more of the same. Thoughts? |
@rosskevin I'm not sure if it would work in this case and if there's something similar for NPM but with Yarn you can use resolutions to overwrite specific dependency versions. |
@traverse I tested with typescript next locally and it works, so it isn't a version conflict. Something on Travis. |
@rosskevin It's also quite weird it's failing to find both |
Same on circleci: https://circleci.com/gh/i18next/react-i18next/8 |
Failed local at my place too: ef1ee56 fixes it |
published in [email protected] |
Adds missing type definitions for the
ready
return value of theuseTranslation
hook and thetReady
prop added by thewithTranslation
HOC, fixes #751.