-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestoneWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Milestone
Description
Iterating a string enum in strict mode is not allowed since 3.6.2. Is this a breaking change or a bug?
Sample code:
// sample.ts
// compile with: `tsc --strict sample.ts`
enum DAYS { Monday = 'monday', Tuesday = 'tuesday' }
for (const a in DAYS) {
const x = DAYS[a]; // <- This is now an error
console.log(x);
}
tsc --strict sample.ts
TSC 3.5.2: Compiles OK
TSC 3.6.2: reports an error:
error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'typeof DAYS'.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
RescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestoneWorking as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug