TypeScript Version: 2.2.0
$ node_modules/.bin/tsc --version
Version 2.2.0
Code
let obj: object = {}
for (const attr in obj) {
const val = obj[attr]
}
Expected behavior:
Compiles without errors.
Actual behavior:
some.ts(3,20): error TS2407: The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter.
This is a new feature, so I'm not sure if I'm using this properly, but the error message says that an object type is allowed, so I expect this behavior to be a bug.
Try spelling object in uppercase: Object
No, object should be acceptable here. Looks like a bug.
Thanks for reporting! I'm looking on it!
+1
thanks @HerringtonDarkholme!
Is this in the next 2.3.0 release?
I pulled down the 2.3.0 release off nom and I'm still seeing this error.
c:\test\sandbox7>tsc --v
Version 2.3.0
c:\test\sandbox7>type a.ts
let obj: object = {}
for (const attr in obj) {
const val = obj[attr]
}
c:\test\sandbox7>tsc a.ts
c:\test\sandbox7>echo %ERRORLEVEL%
0
Most helpful comment
Thanks for reporting! I'm looking on it!