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

docs: fix unwrap literal union #1752

Merged
merged 12 commits into from
Jan 26, 2023
Merged

docs: fix unwrap literal union #1752

merged 12 commits into from
Jan 26, 2023

Conversation

ST-DDT
Copy link
Member

@ST-DDT ST-DDT commented Jan 18, 2023

Restore the unwrapping of literal unions (broken due to the readonly array modifier/type operator).

  • value: LiteralUnion<'a' | 'b'> -> 'a' | 'b' | string
  • namedValue: LiteralUnion<AB> -> AB | string
  • array: readonly LiteralUnion<'a' | 'b'>[] -> readonly ('a' | 'b' | string)[]
  • namedArray: readonly LiteralUnion<AB>[] -> readonly (AB | string)[]

This also fixes an issue with missing parenthesis in union array types.

I found these issues when testing changes for #1732, but the PRs are unrelated to each other.

Preview Diff

Old

grafik

New

grafik

This mainly has an impact on the string module, but also affects weightedArrayElement (See also #1753).

Preview Diff

grafik
->
grafik

(We might want to expand this similar to the usual options object in the future)

Note: We replace LiteralUnions<X, Y> with X | Y because it is shorter and easier to understand (#811).

@ST-DDT ST-DDT added c: bug Something isn't working c: docs Improvements or additions to documentation p: 1-normal Nothing urgent labels Jan 18, 2023
@ST-DDT ST-DDT added this to the v8.0 - Module Re-Shuffling milestone Jan 18, 2023
@ST-DDT ST-DDT requested review from a team January 18, 2023 09:57
@ST-DDT ST-DDT self-assigned this Jan 18, 2023
scripts/apidoc/signature.ts Outdated Show resolved Hide resolved
scripts/apidoc/signature.ts Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jan 18, 2023

Codecov Report

Merging #1752 (4a722db) into next (b86638d) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #1752   +/-   ##
=======================================
  Coverage   99.64%   99.64%           
=======================================
  Files        2340     2340           
  Lines      242669   242669           
  Branches     1112     1112           
=======================================
  Hits       241819   241819           
  Misses        829      829           
  Partials       21       21           

@matthewmayer
Copy link
Contributor

Would there be value in having the generated HTML documents (like ./docs/.vitepress/dist) included in the repo? Then when changes like this are made, it would be easy to see the effect of the changes (effectively a snapshot test).

@ST-DDT
Copy link
Member Author

ST-DDT commented Jan 18, 2023

Would there be value in having the generated HTML documents (like ./docs/.vitepress/dist) included in the repo? Then when changes like this are made, it would be easy to see the effect of the changes (effectively a snapshot test).

@ST-DDT ST-DDT added the s: on hold Blocked by something or frozen to avoid conflicts label Jan 18, 2023
@ST-DDT
Copy link
Member Author

ST-DDT commented Jan 23, 2023

Waiting for #1755
Then I will have another look at readonly && short.

@ST-DDT
Copy link
Member Author

ST-DDT commented Jan 23, 2023

For anybody interested in reviewing this:

docs diff

Documentation changes detected:

(Parameter or return type changed, diff created by #1755)

(generated for 310c78c)

@ST-DDT ST-DDT removed the s: on hold Blocked by something or frozen to avoid conflicts label Jan 23, 2023
@ST-DDT ST-DDT requested a review from a team January 24, 2023 22:25
@ST-DDT ST-DDT requested a review from a team January 25, 2023 14:33
@ST-DDT ST-DDT enabled auto-merge (squash) January 26, 2023 16:04
@ST-DDT ST-DDT merged commit dcb318f into next Jan 26, 2023
@ST-DDT ST-DDT deleted the docs/unwrap-literal-union branch January 26, 2023 16:43
matthewmayer pushed a commit to matthewmayer/faker that referenced this pull request Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: bug Something isn't working c: docs Improvements or additions to documentation p: 1-normal Nothing urgent
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants