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(types): provide strong typing for locales 2 #398

Merged
merged 6 commits into from
Feb 11, 2022
Merged

Conversation

ST-DDT
Copy link
Member

@ST-DDT ST-DDT commented Feb 1, 2022

Update generateLocales.ts to generate proper type definitions in locales/.../index.ts files.

The entirety of this PR was created by the included script with the exception of 5 files where I had to manually add as X (weekday, month, title).

@faker-js/contributors

Currently the script has the following drawbacks/limitations:

  • It is unable to detect that only optional properties are missing and thus it applies Partial<X> to often.
    • I could fix that by adding a DEFINITIONS variant, that only contains required properties. However, I haven't found a way to check that array for correctness at compile time
    • Use LocaleDefinition['module'] as it is already wrapped in Partial<X>
    • Alternatively, we could mark all properties to be optional
    • Or ignore that for now

Lint-Warnings: 502 -> 205

@ST-DDT ST-DDT added the c: feature Request for new feature label Feb 1, 2022
@ST-DDT ST-DDT requested a review from a team February 1, 2022 22:17
@ST-DDT ST-DDT self-assigned this Feb 1, 2022
@ST-DDT ST-DDT requested review from Shinigami92 and a team February 2, 2022 16:16
Shinigami92
Shinigami92 previously approved these changes Feb 3, 2022
src/locales/ne/address/postcode.ts Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Feb 6, 2022

Codecov Report

Merging #398 (c68bb27) into main (6afa92b) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##             main     #398     +/-   ##
=========================================
  Coverage   99.33%   99.34%             
=========================================
  Files        1920     1919      -1     
  Lines      174484   176291   +1807     
  Branches      896      898      +2     
=========================================
+ Hits       173324   175133   +1809     
+ Misses       1104     1102      -2     
  Partials       56       56             
Impacted Files Coverage Δ
src/index.ts 100.00% <100.00%> (ø)
src/locales/af_ZA/address/index.ts 100.00% <100.00%> (ø)
src/locales/af_ZA/company/index.ts 100.00% <100.00%> (ø)
src/locales/af_ZA/index.ts 100.00% <100.00%> (ø)
src/locales/af_ZA/internet/index.ts 100.00% <100.00%> (ø)
src/locales/af_ZA/name/index.ts 100.00% <100.00%> (ø)
src/locales/af_ZA/phone_number/index.ts 100.00% <100.00%> (ø)
src/locales/ar/address/index.ts 100.00% <100.00%> (ø)
src/locales/ar/commerce/index.ts 100.00% <100.00%> (ø)
src/locales/ar/date/index.ts 100.00% <100.00%> (ø)
... and 371 more

Shinigami92
Shinigami92 previously approved these changes Feb 7, 2022
@ST-DDT ST-DDT requested a review from a team February 7, 2022 14:06
@ST-DDT ST-DDT requested a review from a team February 10, 2022 22:30
@ST-DDT ST-DDT merged commit 419e9e2 into main Feb 11, 2022
@ST-DDT ST-DDT deleted the chore/strong-types-2 branch February 11, 2022 18:58
demipel8 pushed a commit to demipel8/faker that referenced this pull request Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: feature Request for new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants