-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
Search Terms: Object.values
Code
enum Role {
Admin = 'ADMIN',
Results = 'RESULTS',
Finish = 'FINISH',
Config = 'CONFIG'
}
Object.values(Role).forEach(role => {
console.log(typeof role); // prints 'string' four times
});
Object.values(Role).includes('hello'); // errors at build timeExpected behavior: Object.values(EnumType) at build time should be returning an array of the same type as the values of the EnumType.
Actual behavior: Object.values(EnumType).includes('enumValueType') errors out with
error TS2345: Argument of type '"enumValueType"' is not assignable to parameter of type 'EnumType'.
It appears as though, at build time, Object.values(EnumType) is parsed as returning an array of EnumTypes.
Error first encountered on Typescript 3.6.2. Still present as of typescript@next.
Playground Link: Playground link. Playground does not appear to be correctly using ES2017 and Typescript 3.6.2/3.7.0 are not available.
jakubwolny, chulanovskyi-bs, Vadiok, hottmanmichael, davidfurlong and 3 more
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug