Closed
Description
Bug Report
π Search Terms
enum, number
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about enums
β― Playground Link
Playground link with relevant code
π» Code
enum TypeA {
A = 0,
B = 1,
C = 2,
}
const valueA1: TypeA = 4; // <-- no error
const valueA2: TypeA = '4';
enum TypeB {
A = '0',
B = '1',
C = '2',
}
const valueB1: TypeB = '4';
const valueB2: TypeB = 4;
π Actual behavior
The number can be assigned to an enum without errors.
π Expected behavior
Errors.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
MartinJohns commentedon Jul 20, 2022
Duplicate of #26362, which provides plenty of reasoning for this behaviour. Used search terms:
enum number in:title
typescript-bot commentedon Jul 22, 2022
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.