Skip to content

For var in object: Var is implicitly any without error #4518

Closed
@M-Pixel

Description

@M-Pixel

In the following statement,

for (let subscription in this._subscriptions) {
    // Do something with subscription
}

The variable subscription is considered type any. Although I'm compiling with noImplicitAny as true, no error is given. Based on the for spec, it seems as if subscription should implicitly be considered string.

Because of this, it's possible to compile with typo functions that will cause errors at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking ChangeWould introduce errors in existing codeCommittedThe team has roadmapped this issueIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions