Vincemynameisvince.hashnode.dev·Mar 20, 2024TypeScript - Custom Types學習資源: Codecademy Enums 枚舉 在做型別註釋的時候,比如使用 Tuples ,變數很多的時,型別註釋也會跟著很多。但大多時候很多都是重複的,所以這時枚舉就派上用場了。 enum Direction { North, South, East, West } 在許多情況下,我們可能想要限制變數的可能值。 例如,上面的程式定義了枚舉方向,代表四個指南針方向:Direction.North, Direction.South, Direction.East, and ...TypeScriptTypeScriptAdd a thoughtful commentNo comments yetBe the first to start the conversation.