We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
we expect not to be able to define a role number which is not in our enum, but we can :|
enum Role { ADMIN, AUTHOR } interface User { role: Role } const user1: User = { role: 1234 }
Compiles with out any Error.
Type 'number' is not assignable to type 'Role'.
but this code gives us correct error message:
Type '"c"' is not assignable to type 'Role'.
enum Role { ADMIN = 'a', AUTHOR = 'b' } interface User { role: Role } const user1: User = { role: 'c' }
The text was updated successfully, but these errors were encountered:
Duplicate of #26362, which provides plenty of reasoning for this behaviour. Used search terms: enum number in:title
enum number in:title
What search terms did you use? You skipped that part of the issue template.
Sorry, something went wrong.
No branches or pull requests
Bug Report
we expect not to be able to define a role number which is not in our enum, but we can :|
🙁 Actual behavior
Compiles with out any Error.
🙂 Expected behavior
Type 'number' is not assignable to type 'Role'.
Different behavior with String
but this code gives us correct error message:
The text was updated successfully, but these errors were encountered: