Closed
Description
Unlike element
in for (let element of iterable) {}
and error
in try {} catch (error) {}
where element
and error
are determined at run-time, key
in for (let key in object) {}
is already known to be a string at compile-time.
I propose we accept an annotation for key
. In other words, the following syntax should be valid:
for (let key: string in object) {}
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript / JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. new expression-level syntax)