Skip to content

Deprecate EnumList #143

@Sleitnick

Description

@Sleitnick

EnumList existed before Luau types. Now that we can create singleton types, we can construct a union of strings to represent an enum.

--!strict

-- Create enum using a union of strings:
type MyEnum = "A" | "B" | "C"

-- Roblox will type-check this to be either A, B, or C, and nothing else:
local myEnum: MyEnum = "A"

The benefits of this:

  • Proper intellisense/linting
  • Serialization (e.g. Can send across network; can save in DataStore)
  • Easier to debug
  • No hidden behavior (they're just strings)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions