"implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." in for-of with strictNullChecks and noImplicitAny #23284
Labels
Duplicate
An existing issue was already created
TypeScript Version: 2.9.0-dev.20180409
Search Terms:
referenced directly or indirectly in its own initializer
Code
Note:
strictNullChecks
andnoImplicitAny
need to be on. As far as I can tell, all the lines are necessary to reproduce the error:Expected behavior:
No error. elements2 should be typed as Element[]
Actual behavior:
'elements2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
This is especially jarring because explicitly typing the variable of a for-loop is not allowed!Playground Link: playground
Related Issues:
#12101 same error in same location which has been fixed. The more specific circumstances here still cause it though.
The text was updated successfully, but these errors were encountered: