Optional properties of function parameter not detected when default parameter created indirectly #43725
Labels
Working as Intended
The behavior described is the intended behavior; this is not a bug
Bug Report
When calling a function with an object which has a default parameter and is destructured with fallback values, optional properties are only inferred correctly if that default parameter is created ad-hoc. If it's a function call or variable reference, the optional properties of the parameter are no longer detected.
🔎 Search Terms
function default parameter optional
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=4.2.3&ssl=13&ssc=1&pln=1&pc=1#code/GYVwdgxgLglg9mABAdzgJwNYGcAUBvRAQwBpEAjRAXkSjRAFNEBfKxAwgLhrvtLK9oNmASjZMAUKky48nbgybCA3OPGhIsBIgAm9YIRAAbKAAVCaQgFsAjDlF5xiJ4jT0oINEnYCefH0KYVCXVoeCRtOHosMCgAdXQMW3Y+VkFGFmpdfSNTcytbYXsJCKiY+MwkuTTFJUQAejryFDQEAHNQQ0MATxd6AEcQGFdtVQgELCgdPQNjMwtLACZWb3lecn90lRDNcMjouISF-CIU6jTmViyZ3PmFovES-fKMI9kNmvrGimQWsHajbq9AZDegjIA
💻 Code
🙁 Actual behavior
Destructuring a function parameter with a default value doesn't mark properties as optional that have a fallback value when the default parameter isn't created ad-hoc.
🙂 Expected behavior
It doesn't make a difference if the default parameter is created ad-hoc or indirectly.
The text was updated successfully, but these errors were encountered: