Let's analyze this demonstration. Initially, an enum is created as follows:
enum myEnum {
a = 'a',
b = 'b'
}
The next step involves creating a similar enum but with the addition of one more numeric value! This alteration is crucial.
enum myExtendedEnum {
a = "a",
b = "b",
//any number can be assigned here
c = 11,
}
Now observe the following code snippet.
const returnsMyEnum = function() : myEnum {
return 48;
}
const returnMyExtendedEnum = function() : extendedEnum {
return 48;
}
Can you determine which function above is problematic for TypeScript? One might assume both are flawed, however, surprisingly only the returnsMyEnum
function raises issues. Do you comprehend what's happening here or should I pursue opening a bug report in the TypeScript repository?