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

fix: ensure array types #4266

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dnalborczyk
Copy link
Contributor

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other: internal type fix

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

@dnalborczyk dnalborczyk marked this pull request as draft November 6, 2021 03:25
@dnalborczyk dnalborczyk force-pushed the fix-ensure-array-types branch 3 times, most recently from ad1daa0 to f4af4ca Compare November 6, 2021 16:31
@codecov
Copy link

codecov bot commented Nov 6, 2021

Codecov Report

Merging #4266 (a0bcfda) into master (8d98341) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4266      +/-   ##
==========================================
- Coverage   98.39%   98.39%   -0.01%     
==========================================
  Files         204      204              
  Lines        7312     7310       -2     
  Branches     2084     2083       -1     
==========================================
- Hits         7195     7193       -2     
  Misses         58       58              
  Partials       59       59              
Impacted Files Coverage Δ
src/utils/ensureArray.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d98341...a0bcfda. Read the comment docs.

@@ -53,7 +54,7 @@ export function normalizeInputOptions(config: InputOptions): {
moduleContext: getModuleContext(config, context),
onwarn,
perf: config.perf || false,
plugins: ensureArray(config.plugins),
plugins: ensureArray(config.plugins) as Plugin[],
Copy link
Member

Choose a reason for hiding this comment

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

Is that an improvement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is that an improvement?

🤣

depends on the point of view. currently, maybe not so much. when I cruise thru the code I see a lot of type assertions and non-null assertions (!), where I feel like I want to fix those. the problem is that no matter which route you go you always find yourself really fast in a rabbit hole 😉 because the intensions are not clear. so usually I revert and let it be.

the current ensure array typing is incorrect in the sense that the generic < T > already covers false | undefined | null. I believe it's just there to make the type checker happy, but the root problem is elsewhere.

that's why I left this PR as a draft, I'll have a couple questions when I get back to it.

Copy link
Member

Choose a reason for hiding this comment

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

Sure 😉, I really like that you look through the code search for ways to make it better!

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.

None yet

2 participants