Consider not filtering out properties that are explicitely set to undefined
See original GitHub issueThere are use-cases in which it makes sense to set a property to undefined
and still expect it to be copied. Object.assign()
does not filter out such properties, either.
What’s the reason for them to be filtered in node-extend?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
Filter to remove undefined items is not picked up by ...
The solution is to pass a type-guard function that tells TypeScript that you're filtering out the undefined part of the type:
Read more >Distinguish missing and undefined · Issue #13195
TypeScript Version: 2.1.4 Code Current, with --strictNullChecks on, the typescript compiler seems to treat interface Foo1 { bar?
Read more >Understanding the difference between null and undefined ...
We'll look at the difference between null and undefined values. The value null must be explicitly set for a property. For example, here...
Read more >A Definitive Guide to Handling Errors in JavaScript
Getting tripped up by errors in your JavaScript? We'll show you how to tame those errors so you can get back to developing...
Read more >Documentation - Narrowing
Argument of type 'string | number' is not assignable to parameter of type ... But it turns out that in JavaScript, typeof null...
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 FreeTop 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
Top GitHub Comments
That exact advice is what I expect to be more noticeable. Since this module is just called extend, it could lead to confusion. I know that the very first sentence is that it mirrors JQuery’s extend function, but for people who is not familiar with JQuery it means nothing. A small explanation of the unexpected behaviors would be nice, and of course your recommendation for another polyfill
Thanks and regards
Ah, I understand what this issue is about now.
Object.assign
does do what you mean - in other words,Object.assign({}, { value: 3 }, { value: undefined })
will result in{ value: undefined }
.However, this module is exclusively to mirror jQuery’s “extend” function, so that’s the behavior it will preserve.
I recommend https://npmjs.com/object.assign if you want an official polyfill for the native language feature.