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: add autocomplete support for locales #248

Merged
merged 2 commits into from
Jan 23, 2022
Merged

feat: add autocomplete support for locales #248

merged 2 commits into from
Jan 23, 2022

Conversation

ST-DDT
Copy link
Member

@ST-DDT ST-DDT commented Jan 21, 2022

I will automate the generation/update for KnownLocales in a later PR.

The is the TypeScript related part for #210

@ST-DDT ST-DDT requested a review from a team as a code owner January 21, 2022 15:41
@netlify
Copy link

netlify bot commented Jan 21, 2022

✔️ Deploy Preview for vigilant-wescoff-04e480 ready!

🔨 Explore the source changes: 77e08ba

🔍 Inspect the deploy log: https://app.netlify.com/sites/vigilant-wescoff-04e480/deploys/61eb2cb9c1bb40000987678b

😎 Browse the preview: https://deploy-preview-248--vigilant-wescoff-04e480.netlify.app

@ST-DDT ST-DDT marked this pull request as draft January 21, 2022 15:43
@ST-DDT
Copy link
Member Author

ST-DDT commented Jan 21, 2022

This doesn't work yet due to export = locales; in src/locales/index.ts.

@ST-DDT
Copy link
Member Author

ST-DDT commented Jan 21, 2022

This PR depends on #249

@Shinigami92 Shinigami92 added the p: 1-normal Nothing urgent label Jan 21, 2022
src/index.ts Outdated Show resolved Hide resolved
Shinigami92
Shinigami92 previously approved these changes Jan 21, 2022
@Shinigami92 Shinigami92 requested a review from a team January 21, 2022 17:41
@Shinigami92 Shinigami92 marked this pull request as ready for review January 21, 2022 17:41
@Shinigami92 Shinigami92 requested a review from a team January 21, 2022 22:40
@Shinigami92 Shinigami92 linked an issue Jan 21, 2022 that may be closed by this pull request
@prisis prisis merged commit c1f2b09 into faker-js:main Jan 23, 2022
@ST-DDT ST-DDT deleted the feature/locales/autocomplete branch January 23, 2022 11:36
@@ -56,7 +56,67 @@ import zh_CN from './zh_CN';
import zh_TW from './zh_TW';
import zu_ZA from './zu_ZA';

const locales: { [lang: string]: LocaleDefinition } = {
export type KnownLocale =
Copy link
Member

Choose a reason for hiding this comment

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

Couldn't you use keyof typeof locales, so we don't have to repeat the same thing again?

Copy link
Member

Choose a reason for hiding this comment

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

Wont this result in a circular type?
One of them needs to be defined first, or not?

Copy link
Member

Choose a reason for hiding this comment

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

yes, first create the locales, and then below it, create the KnownLocale type. There is no circular reference if they stay in the same file.

Copy link
Member

Choose a reason for hiding this comment

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

Something like this I had in mind:

const locales = {
  af_ZA,
  ar,
  ...
};

export type KnownLocale = keyof typeof locales

export default locales;

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you please create an issue (or PR) for that?
I currently work on something different and don't want to forget about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p: 1-normal Nothing urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: document supported locales
4 participants