Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent behaviour of enum. #50507

Closed
pociej opened this issue Aug 29, 2022 · 3 comments
Closed

Inconsistent behaviour of enum. #50507

pociej opened this issue Aug 29, 2022 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@pociej
Copy link

pociej commented Aug 29, 2022

πŸ”Ž Search Terms

wrong enum behaviour numeric enum wrong check inconsistent enum behaviour

πŸ•— Version & Regression Information

I see it in all versions of ts

⏯ Playground Link

https://tsplay.dev/N9PO8w

πŸ’» Code

enum myEnum {
    a = 'a',
    b = 'b',
}


enum extendedEnum {
    a = "a", 
    b = "b", 
    //use any number here, 11 is random value 
    c = 11, 
}


//use any number here, 48 is random value 

const returnsMyEnum = function() : myEnum {
    return 48;  
}

const returnMyExtendedEnum = function() : extendedEnum {
    return 48; 
}

πŸ™ Actual behavior

Only returnsMyEnum gives typescript error.

πŸ™‚ Expected behavior

Both functions are wrong.

@jcalz
Copy link
Contributor

jcalz commented Aug 29, 2022

Duplicate of #26362

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Aug 29, 2022
@fatcerberus
Copy link

// use any number here, 11 is random value 
c = 11,

I’m suddenly reminded of this
https://xkcd.com/221/

@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants