Skip to content

feat: add autocomplete support for locales#248

Merged
prisis merged 2 commits intofaker-js:mainfrom
ST-DDT:feature/locales/autocomplete
Jan 23, 2022
Merged

feat: add autocomplete support for locales#248
prisis merged 2 commits intofaker-js:mainfrom
ST-DDT:feature/locales/autocomplete

Conversation

@ST-DDT
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Comment thread src/index.ts Outdated
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
Comment thread src/locales/index.ts
import zu_ZA from './zu_ZA';

const locales: { [lang: string]: LocaleDefinition } = {
export type KnownLocale =
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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