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

🌱 Setup TS to know about .filter(Boolean) #1416

Merged
merged 1 commit into from
Sep 28, 2023

Conversation

sjd78
Copy link
Member

@sjd78 sjd78 commented Sep 28, 2023

With array-filter-Boolean.ts, TS will select a better Array.filter() override so this kind of thing will work automatically without an explicit type casting:

const a: Array<string | undefined | null> = ["A", "B", undefined, null, "C", ""];

const b: string[] = a.filter(Boolean);
// b = ["A", "B", "C"]

See https://www.karltarvas.com/typescript-array-filter-boolean.html
See https://stackoverflow.com/a/51390763/1470607

With `array-filter-Boolean`, TS will select a better Array.filter()
override so this kind of thing will work automatically without an
explicit type casting:

```js
const a: Array<string | undefined | null> = ["A", "B", undefined, null, "C"];
const b: string[] = a.filter(Boolean);
```

See https://www.karltarvas.com/typescript-array-filter-boolean.html
See https://stackoverflow.com/a/51390763/1470607

Signed-off-by: Scott J Dickerson <[email protected]>
@codecov
Copy link

codecov bot commented Sep 28, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (3b7f853) 41.24% compared to head (c667c9b) 41.24%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1416   +/-   ##
=======================================
  Coverage   41.24%   41.24%           
=======================================
  Files         138      138           
  Lines        4347     4347           
  Branches     1005     1005           
=======================================
  Hits         1793     1793           
  Misses       2542     2542           
  Partials       12       12           
Flag Coverage Δ
client 41.24% <33.33%> (ø)
server ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...s/components/application-form/application-form.tsx 65.94% <100.00%> (ø)
client/src/app/utils/model-utils.tsx 35.06% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@ibolton336 ibolton336 left a comment

Choose a reason for hiding this comment

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

Nice find!

@ibolton336 ibolton336 merged commit 76a2645 into konveyor:main Sep 28, 2023
6 checks passed
@sjd78 sjd78 deleted the array_filter_Boolean branch September 29, 2023 19:37
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.

2 participants