How to fix Enum member name must be followed by ',' ':' or '}' in TypeScript

TypeScriptBEGINNERMEDIUMUpdated Dec 8, 2025· 115 views

This TypeScript syntax error occurs when an enum member declaration is followed by an invalid character or separator. The most common cause is using a colon (:) instead of an equals sign (=) when assigning values, or forgetting a comma between members.

Quick fix

Fixes TS1357

// WRONG - uses colon (:)
enum Status {
  Active: 1,      // ❌ Error: expected ',' '=' or '}'
  Inactive: 0,
  Pending: 2
}

// CORRECT - uses equals sign (=)
enum Status {
  Active = 1,     // ✅ Valid syntax
  Inactive = 0,
  Pending = 2
}
  1. Check for colon instead of equals sign
  2. Verify commas separate all members
  3. Remove type annotations from enum members
  4. Fix string enum syntax
typescript — error
// WRONG - uses colon (:)
enum Status {
Active: 1, // ❌ Error: expected ',' '=' or '}'
Inactive: 0,
Pending: 2
}
// CORRECT - uses equals sign (=)
enum Status {
Active = 1, // ✅ Valid syntax
Inactive = 0,
Pending = 2
}
Enum member name must be followed by ',' ':' or '}'

What this error means

The "Enum member name must be followed by ',' ':' or '}'" error (TS1357) indicates that TypeScript encountered an invalid character immediately after an enum member name. TypeScript has strict syntax rules for enum declarations: each member must be followed by one of three characters: 1. A comma (,) to separate it from the next member 2. An equals sign (=) to assign a specific value to that member 3. A closing brace (}) to end the enum declaration This error most frequently occurs when developers accidentally use a colon (:) instead of an equals sign (=) when assigning values to enum members. This mistake is particularly common for those coming from languages like Python or for those who confuse enum syntax with object literal or type annotation syntax. The error message was specifically improved in TypeScript to explicitly mention the closing brace (}) as an acceptable character, making it clearer what valid options exist at that position in the enum definition.

Typical symptoms

  • Compilation fails with TS1357 error message
  • IDE shows red squiggly line after enum member name
  • Error points to a specific character after an enum member
  • Code works in JavaScript-like syntax but fails in TypeScript strict parsing
  • Syntax highlighting appears broken in enum declaration
  • Build process stops at enum definition file

Common causes

  1. Using a colon (:) instead of equals sign (=) when assigning enum values
  2. Missing comma between consecutive enum members
  3. Using semicolon (;) instead of comma (,) to separate members
  4. Including illegal characters or operators after member name
  5. Adding type annotations to enum members (not allowed)
  6. Attempting to use object literal syntax inside enum declaration
  7. Copy-pasting code from a different syntax context (objects, interfaces)
  8. Trailing characters or typos immediately after member name

How to fix "Enum member name must be followed by ',' ':' or '}'"

1Check for colon instead of equals sign

The most common cause is using a colon (:) when you should use an equals sign (=):

typescript
// WRONG - uses colon (:)
enum Status {
  Active: 1,      // ❌ Error: expected ',' '=' or '}'
  Inactive: 0,
  Pending: 2
}

// CORRECT - uses equals sign (=)
enum Status {
  Active = 1,     // ✅ Valid syntax
  Inactive = 0,
  Pending = 2
}

This mistake often happens when developers confuse enum syntax with:
- Object literal syntax: { key: value }
- Interface property syntax: interface Foo { prop: Type }
- Type annotation syntax: const x: Type = value

Replace all colons with equals signs in your enum value assignments.

2Verify commas separate all members

Each enum member must be separated from the next by a comma:

typescript
// WRONG - missing commas
enum Color {
  Red = "#FF0000"
  Green = "#00FF00"    // ❌ Error: expected ','
  Blue = "#0000FF"
}

// WRONG - using semicolons
enum Color {
  Red = "#FF0000";     // ❌ Error: expected ','
  Green = "#00FF00";
  Blue = "#0000FF"
}

// CORRECT - commas between members
enum Color {
  Red = "#FF0000",     // ✅ Valid
  Green = "#00FF00",
  Blue = "#0000FF"     // Trailing comma is optional
}

Trailing commas after the last member are allowed and often recommended for cleaner diffs.

3Remove type annotations from enum members

Enum members cannot have explicit type annotations:

typescript
// WRONG - type annotations not allowed
enum HttpStatus {
  OK: number = 200,           // ❌ Error
  NotFound: number = 404,
  ServerError: number = 500
}

// CORRECT - no type annotations needed
enum HttpStatus {
  OK = 200,                   // ✅ TypeScript infers the type
  NotFound = 404,
  ServerError = 500
}

TypeScript automatically infers enum member types:
- Numeric enums have number type
- String enums have string type
- The enum itself is the type when used in code

4Fix string enum syntax

String enums require equals signs and quotes around values:

typescript
// WRONG - various string enum mistakes
enum Direction {
  North: "N",        // ❌ Colon instead of equals
  East = "E"
  South = "S",       // ❌ Missing comma after East
  West: 'W'          // ❌ Colon instead of equals
}

// CORRECT - proper string enum
enum Direction {
  North = "N",       // ✅ Equals sign + comma
  East = "E",
  South = "S",
  West = "W"
}

String enums require explicit initialization for every member:

typescript
// WRONG - missing initializer
enum Direction {
  North,             // ❌ String enums need explicit values
  East = "E",
  South = "S"
}

// CORRECT - all members initialized
enum Direction {
  North = "N",
  East = "E",
  South = "S",
  West = "W"
}
5Check for illegal characters or expressions

Ensure no unexpected characters appear after member names:

typescript
// WRONG - various illegal characters
enum Priority {
  Low = 1,
  Medium = 2 + 1,    // ✅ Computed values are allowed
  High:: 3,          // ❌ Double colon invalid
  Critical = = 4,    // ❌ Double equals invalid
  Urgent! = 5        // ❌ Exclamation mark invalid
}

// CORRECT - only valid syntax
enum Priority {
  Low = 1,
  Medium = 2,
  High = 3,
  Critical = 4,
  Urgent = 5
}

Valid after an enum member name:
- , to add another member
- = to assign a value
- } to close the enum
- Nothing else is allowed

6Review computed and auto-incremented values

Numeric enums support auto-increment and computed values:

typescript
// Auto-increment (no assignment needed)
enum Level {
  Beginner,          // = 0 (automatic)
  Intermediate,      // = 1 (auto-increment)
  Advanced          // = 2 (auto-increment)
}

// Explicit numbering
enum Level {
  Beginner = 1,      // Start at 1
  Intermediate,      // = 2 (auto-increment)
  Advanced          // = 3 (auto-increment)
}

// Computed values
enum Permission {
  None = 0,
  Read = 1 << 0,     // = 1
  Write = 1 << 1,    // = 2
  Execute = 1 << 2   // = 4
}

// WRONG - mixing requires initialization
enum Mixed {
  First = "first",
  Second,            // ❌ Error: must initialize after string member
  Third = 3
}

// CORRECT - explicit initialization
enum Mixed {
  First = "first",
  Second = "second", // ✅ All string members initialized
  Third = "third"
}

Advanced notes

### Enum Syntax vs Object Literal Syntax

Developers often confuse enum syntax with object literals because they look similar:

typescript
// Object literal - uses colons
const statusObject = {
  active: 1,      // Colon for key-value pairs
  inactive: 0
};

// Enum - uses equals signs
enum StatusEnum {
  Active = 1,     // Equals for member assignments
  Inactive = 0
}

The syntax difference exists because:
- Objects are runtime values with key-value pairs
- Enums are compile-time constructs that generate both types and values
- Object keys can be any valid identifier; enum members become type literals

### Const Enums and Syntax

The same syntax rules apply to const enums:

typescript
// WRONG
const enum Mode {
  Dev: "development",    // ❌ Colon not allowed
  Prod: "production"
}

// CORRECT
const enum Mode {
  Dev = "development",   // ✅ Equals sign
  Prod = "production"
}

Const enums are inlined at compile time and removed from generated JavaScript, but their syntax is identical to regular enums.

### IDE Auto-Fix

Most modern IDEs can auto-fix this error:

- VS Code: Click the lightbulb icon or press Cmd/Ctrl + . and select "Replace ':' with '='"
- WebStorm/IntelliJ: Press Alt + Enter and select the quick fix
- ESLint: The @typescript-eslint plugin can auto-fix with --fix flag

### Heterogeneous Enums (Not Recommended)

TypeScript technically allows mixing string and numeric members, but it's discouraged:

typescript
// Allowed but not recommended
enum Mixed {
  Yes = 1,
  No = "NO",
  Maybe = 2
}

This pattern is confusing and rarely useful. Stick to either numeric or string enums, not both.

### Ambient Enum Declarations

When declaring enums in .d.ts files or with declare, the same syntax applies:

typescript
// In a .d.ts file
declare enum ExternalEnum {
  First = 1,     // Still uses equals, not colon
  Second = 2
}

Ambient enums describe shapes of existing enums from external sources but follow identical syntax rules.

### Migration from JavaScript Objects

If migrating from a JavaScript pattern:

javascript
// Before (JavaScript object)
const Status = {
  ACTIVE: 'active',
  INACTIVE: 'inactive'
};
typescript
// After (TypeScript enum) - note the syntax change
enum Status {
  ACTIVE = 'active',      // Colon → Equals
  INACTIVE = 'inactive'
}

Or use as const to keep object syntax:

typescript
const Status = {
  ACTIVE: 'active',
  INACTIVE: 'inactive'
} as const;

type StatusValue = typeof Status[keyof typeof Status];

Frequently asked questions

What does "TS1357" mean?
The "Enum member name must be followed by ',' ':' or '}'" error (TS1357) indicates that TypeScript encountered an invalid character immediately after an enum member name. TypeScript has strict syntax rules for enum declarations: each member must be followed by one of three characters: 1. A comma (,) to separate it from the next member 2.
How do I fix "TS1357"?
This TypeScript syntax error occurs when an enum member declaration is followed by an invalid character or separator. The most common cause is using a colon (:) instead of an equals sign (=) when assigning values, or forgetting a comma between members.
What causes "TS1357"?
Using a colon (:) instead of equals sign (=) when assigning enum values Missing comma between consecutive enum members Using semicolon (;) instead of comma (,) to separate members
Is the "TS1357" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading