You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The not recognized assignment in the callback is a duplicate of #9998.
That your type annotation is not used is working as intended. Assigning a value narrows the variable. The type annotation limits what values can be assigned to it.
π Search Terms
wrong type inference
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=5.5.0-dev.20240313#code/DYUwLgBAhgXBDOYBOBLAdgcwgHwmgrsMBALx6HADcAUAMYD2aiEARqRANoCMANAEw8AzAF0aLAHQAzekgCiUWgAsAFMtoBKUgD4IAb2oRo7AMrJ0GNepoBfK9RSTlUCAEISZAkXX7DhgPR+RijweCAAbiBIEOgQYIrBrMD0tADWBr4MTPSg4kkWUHbW1EA
π» Code
π Actual behavior
variable
a
is inferred asnull
in the if block, causing the variablea
in the if block to be typenever
.π Expected behavior
a
should be inferred asstring
Additional information about the issue
This workaround magically works.
The text was updated successfully, but these errors were encountered: