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
functionwrap(val: unknown){if(typeofval!=='string'){thrownewError();}console.log(val)// "val" is narrowed to "string" as expected.return{getValue(){returnval;// "val" is narrowed to "string" as expected.},getvalue(){returnval;// "val" is still "unknown".}}}
🙁 Actual behavior
The type is not correctly narrowed inside getters.
🙂 Expected behavior
The type to be narrowed inside getters, as is the case for references in other parts of the function.
The text was updated successfully, but these errors were encountered:
Bug Report
🔎 Search Terms
narrow, narrowing, getter, unknown
🕗 Version & Regression Information
I noticed this bug on
v4.1.2
. I can also reproduce it on older versions such asv2.8.1
Please keep and fill in the line that best applies:
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
The type is not correctly narrowed inside getters.
🙂 Expected behavior
The type to be narrowed inside getters, as is the case for references in other parts of the function.
The text was updated successfully, but these errors were encountered: