Skip to content

[TS2.5 regression] Object.values(someEnum) returns string[] (not any[]/number[]) #21089

@mprobst

Description

@mprobst

TypeScript Version: 2.7.0-dev.201xxxxx

Code

enum X {A, B}

const xs = Object.values(X);
xs.includes(1);

Expected behavior:

In TS2.5, this used to compile, because xs was any[].

Actual behavior:

In TS2.6+, xs is string[]. That's wrong:

> Object.values({A: 1, B: 2})
[ 1, 2 ]

Related:

Curiously, this only happens for enums. {[k: ...}: V} style objects work fine.

const z: {[k: string]: number} = {
  A: 1
}
const zs = Object.values(z);
zs.includes(1);

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions