unjs / defu

๐ŸŒŠ Assign default properties recursively
MIT License
1.02k stars 21 forks source link

chore: use optional chaining #112

Closed ferferga closed 10 months ago

ferferga commented 11 months ago

๐Ÿ”— Linked issue

Review comments from #104

โ“ Type of change

๐Ÿ“š Description

Refer to @pi0 in this comment. I think the optional chaining it's still relevant.

๐Ÿ“ Checklist

pi0 commented 10 months ago

Thanks for splitting this part of the change. Can you please remind me why this change was required? Purely for code readability?

ferferga commented 10 months ago

@pi0 Yes, exactly.

pi0 commented 10 months ago

Ah, thanks for confirming. If this is only the case, I think it might be better to keep it as is.

I also really want to get rid of legacy syntaxes and prefer new ones but optional chaining can be particularly tricky to use especially in defu which is used in many many different projects. Many of them use Nuxt 2 with webpack 4 which does not understand this syntax (natively) as it uses older acorn parser even tough all recent browsers support it.