Open
Description
TypeScript Version: 3.3.0-dev.20190105
Search Terms: evolving array type, indexOf
Code
const arr = [];
arr.push(1);
while (true) {
const index = arr.indexOf(1);
arr[index] = 1;
}
Expected behavior:
No errors.
Actual behavior:
'index' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
Playground Link: (turn on noImplicitAny
)
Related Issues: #19955
In the wild: GoogleChrome/lighthouse#6874 (comment). Note @brendankenny's educated guess on what is going on.