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
letiNext;for(leti=0;i<10;i=iNext){// ^? let iNext: numberif(i==5){iNext='bad';continue;}iNext=i+1;}
π Actual behavior
The type of iNext is an evolving any. It evolved to number (at the point of i = iNext), which is incorrect because iNext = 'bad' can assign it a string. The assignment before continue doesn't get included in the type.
π Expected behavior
The type of iNext should evolve to string | number as measured at i = iNext because either the assignment iNext = 'bad' or iNext = i + 1 are on a control flow path between let iNext and i = iNext.
This should give an error because i has type number.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
π Search Terms
"evolving any", "implicit any", "for loop continue", "incorrect inference"
π Version & Regression Information
β― Playground Link
Playground link with relevant code: https://www.typescriptlang.org/play/?ts=5.7.2#code/DYUwLgBAlgciAeYDcAoAZgewE4QBSkiggF4IAGJaCAHggEYKrTYEwBKCAbxQl4gHp+fYSNHCAegH4efKGjxFipAKwduY6HEQkIAcgBGAQwAmu1BoDGGAHZgo1gK4hzfAL4zeLbcwgBqeqiuQA
π» Code
π Actual behavior
The type of
iNext
is an evolving any. It evolved tonumber
(at the point ofi = iNext
), which is incorrect becauseiNext = 'bad'
can assign it a string. The assignment beforecontinue
doesn't get included in the type.π Expected behavior
The type of
iNext
should evolve tostring | number
as measured ati = iNext
because either the assignmentiNext = 'bad'
oriNext = i + 1
are on a control flow path betweenlet iNext
andi = iNext
.This should give an error because
i
has typenumber
.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: