Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected implicit any for return value of Array<T>.indexOf #29290

Open
connorjclark opened this issue Jan 7, 2019 · 1 comment
Open

Unexpected implicit any for return value of Array<T>.indexOf #29290

connorjclark opened this issue Jan 7, 2019 · 1 comment
Labels
Bug A bug in TypeScript Domain: Control Flow The issue relates to control flow analysis
Milestone

Comments

@connorjclark
Copy link
Contributor

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.

@weswigham weswigham added Bug A bug in TypeScript Domain: Control Flow The issue relates to control flow analysis labels Jan 8, 2019
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 14, 2019
@connorjclark
Copy link
Contributor Author

still an issue in 3.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Control Flow The issue relates to control flow analysis
Projects
None yet
Development

No branches or pull requests

3 participants