Skip to content

Conversation

@sschw
Copy link
Contributor

@sschw sschw commented Jan 6, 2026

TypeScript does not allow fully numeric string enum names, see example:

enum Test {
  "1"      = "1", // invalid
  "0"      = "0", // invalid
  "-1"     = "-1", // invalid
  "3.33"   = "3.33" // invalid
  // However
  "01"     = "01", // valid
  "00"     = "00", // valid
  "-01"    = "-01", // valid
  "1 Apple" = "1 Apple", // valid
}

Added a check to specifically only converting the valid numbers by their string representative.

enum Test {
  One = "1",
  Zero = "0",
  MinusOne = "-1",
  ThreePointThreeThree = "3.33"
  // However it keeps all valid once as is.
  "01"     = "01", 
  "00"     = "00", 
  "-01"    = "-01", 
  "1 Apple" = "1 Apple", 
}

Also added "minus " and " point [...]" to the convert function.

@sschw sschw force-pushed the fix-enum-string-numbers branch from 7936b87 to 32c84a4 Compare January 6, 2026 16:21
@fabien0102 fabien0102 merged commit bf87c14 into fabien0102:main Jan 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants