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

feat: improved typings for translate function so now it returns string instead of any #6

Closed
wants to merge 3 commits into from

Conversation

tkvlnk
Copy link
Collaborator

@tkvlnk tkvlnk commented Mar 23, 2021

No description provided.

@tkvlnk tkvlnk requested a review from varzager March 23, 2021 09:37
README.md Outdated
@@ -99,7 +101,9 @@ import React, {createContext, useContext, FC,} from 'react';

export type ILocaleKeys = ReturnType<typeof LocaleKeys>;

export function LocaleKeys(translate: Function) {
type AbstractTranslateFunction = (key: string) => string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think u meant to write here like in the localeKeysFunction.template.ts :
type AbstractTranslateFunction = (...args: any[]) => string;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm yes...
gimme some time
I will try to infer the return type properly to address the concern you shared on slack (that someone could use the object in return type)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see you updated below the actual template code.
maybe update the readme as well?

@tkvlnk tkvlnk requested a review from varzager August 30, 2021 21:36
@tkvlnk
Copy link
Collaborator Author

tkvlnk commented Aug 30, 2021

hey @varzager seems like aligning the type to the return type of the i18next is the best option to avoid any in return type
at least as for now

@tkvlnk tkvlnk closed this Oct 4, 2021
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

Successfully merging this pull request may close these issues.

2 participants