Closed
Description
Bug Report
π Search Terms
7022, circular
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about Common "Bugs" That Aren't Bugs
β― Playground Link
Playground link with relevant code
π» Code
let a : {prop: string} | undefined = undefined;
for (let x=0; x<2; x++) {
const dep = a === undefined ? "a" : "b";
a = {prop: dep}
}
π Actual behavior
'dep' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
If not inside any type of cycle (e.g. while (true)
), dep is correctly typed as "a" | "b"
(see the playground link). So the actual value of a
has not been used in the type information. Even if it has been the case, the cycle should break because a.prop
is strongly defined and is not dependant in any case on the a = {prop: dep}
assignment
π Expected behavior
dep
typed as "a" | "b"
even in the cycle
Similar issues
I've found few simillar issues (e.g. 49837), but not one as simple as this case.
Metadata
Metadata
Assignees
Labels
No labels