Regression - Array.filter
See original GitHub issueBug Report
Array filter have possibly wrong signature or 4.8 introduced “Unconstrained Generics No Longer Assignable to {}” introduced type error
🔎 Search Terms
🕗 Version & Regression Information
After the update to 4.8.2
⏯ Playground Link
💻 Code
export const serializeParams = <T extends {}>(query: T): HttpParams => {
return new HttpParams().appendAll(
Object.fromEntries(Object.entries(query))
)
};
export const serializeParams2 = <T extends {}>(query: T): HttpParams => {
return new HttpParams().appendAll(
Object.fromEntries(Object.entries(query).filter(val => val[1] !== undefined))
)
};
export const serializeParams3 = <T extends {}>(query: T): HttpParams => {
return new HttpParams().appendAll(Object.fromEntries(Object.entries(query)
.filter(([_, value]) => value !== undefined)
.map(([key, value]) => {
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
return [key, JSON.stringify(value)];
} else {
return [key, value ?? ''];
}
})));
};
export const serializeParams4 = <T extends {}>(query: T): HttpParams => {
const entries = Object.entries(query)
.filter(([_, value]) => value !== undefined)
.map(([key, value]) => {
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
return [key, JSON.stringify(value)];
} else {
return [key, value ?? ''];
}
});
return new HttpParams().appendAll(Object.fromEntries(entries)); // here very weird - moving body to separate const fixes type error in VS code but build still fails with error
};
🙁 Actual behavior
unfiltered and filtered arrays behave differently
🙂 Expected behavior
unfiltered and filtered arrays behave the same
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
JavaScript filter array by data from another - Stack Overflow
And I have an array with ids [1, 3, 5],. How can I filter the array object to leave records only with id's...
Read more >statsmodels.regression.recursive_ls.RecursiveLS.filter
Array of parameters at which to evaluate the loglikelihood function. transformedbool, optional. Whether or not params is already transformed. Default is True ...
Read more >Array.prototype.filter() - JavaScript - MDN Web Docs
The filter() method creates a shallow copy of a portion of a given array, filtered down to just the elements from the given...
Read more >Should You Use .includes or .filter to Check if An Array ...
If you need to know if a JavaScript array contains an item, you have a couple of options other than just writing a...
Read more >Filter disturbances through regression model with ARIMA errors
This MATLAB function filters errors to produce responses, innovations, and unconditional disturbances of a univariate regression model with ARIMA time ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This should probably be replaced with a list of terms people can search for to find this issue and related issues.
@MartinJohns Yes, I can confirm that. All the versions I tried raise the same error. I didn’t agree with the OP either. (I am just a passer-by.)