-
-
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
types(Trans): add typechecking on context
prop
#1732
Conversation
@stefan-schweiger can you review this and check if it's ok for you? |
Already did a short look when I saw the PR and from my side every thing seems in order |
ok, will merge and release in the next hour(s) |
thank you both... it's included in v14.1.0 |
KPrefix = undefined, | ||
TContext extends string | undefined = undefined, | ||
TOpt extends TOptions & { context?: TContext } = { context: TContext }, |
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.
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.
Does it still correctly handle the typings for the context property
of the Trans
component?
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.
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.
fixes #1730.
This is technically a breaking change since it change
Trans
andTransProps
type parameters, however I don't think usually people explicit them when using the component... but who knows 🤷.I tried to replicate a type parameter structure similar to the
TFunction
,however, looks like that using a single
TOpt
type parameter doesn't pass the property values (likecontext
) down toTransProps
properly soParseKeys
is not aware of the context value.The only alternative is to add a new type parameter and pass it down the chain, which is basically what @stefan-schweiger proposed in the above linked issue (Thanks 🙏).
Checklist
npm run test