Object spread incorrectly introduces undefined value type in TS 4.2 #43045
Labels
Fix Available
A PR has been opened for this issue
Needs Investigation
This issue needs a team member to investigate its status.
Milestone
Bug Report
This was the one type error I got when I updated my project from TS 4.1 → 4.2. It's a false positive so I figured I'd file an issue in case others run into it as well. I assume this is considered an acceptable loss from this change in the release notes, but it is a false positive and regression from 4.1 nonetheless!
🔎 Search Terms
Possibly related to #13195
🕗 Version & Regression Information
⏯ Playground Link
Compiler Options
Playground Link: Provided
💻 Code
Output
🙁 Actual behavior
TypeScript says that
v
can beundefined
, which it cannot. This leads to the type error in the call toencodeURIComponent
.🙂 Expected behavior
v
can never beundefined
at runtime, so the error is a false positive. This was not an error in TypeScript 4.1.The root cause is that the type of
obj
is inferred aswhereas in TS 4.1 the same inferred type shows up as:
The text was updated successfully, but these errors were encountered: