wiki/content/20200930110721-typescript_enums.md

22 lines
315 B
Markdown
Raw Normal View History

2024-05-06 20:40:05 +00:00
---
id: 4e52541b-5119-4228-97b2-f17f5a23b138
title: TypeScript Enums
---
# Syntax
``` typescript
enum CardSuit {
Clubs,
Diamonds,
Hearts,
Spades
}
// Sample usage
var card = CardSuit.Clubs;
// Safety
card = "not a member of card suit"; // Error : string is not assignable to type `CardSuit`
```