Skip to content

fix(enums)!: keep namespace in enum type names - #141

Merged
skryukov merged 3 commits into
mainfrom
fix/namespaced-enum-names
Nov 16, 2026
Merged

skryukov merged 3 commits into
mainfrom
fix/namespaced-enum-names

Conversation

@skryukov

@skryukov skryukov commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Closes #138.

Problem

Enum type names were built from the model name without its namespace. Course::Build and Project::Build with a state enum both produced BuildState, and only one of them was written to Enums.ts. Nothing warned about it.

Change

  • Enum type names now use the full class name: Course::Build + state gives CourseBuildState. This matches how serializer type names already keep the namespace.
  • A warning is logged when two enums with different values still end up with the same name (for example Course::Build and CourseBuild). The first one is generated, as before.

Breaking

Enum types of namespaced models are renamed, so imports of those types need updating. Models without a namespace are not affected. Planned for 0.15.0.

Tests

New spec/typelizer/namespaced_enum_spec.rb with two examples: same-named models in different namespaces get separate enum names, and the warning fires on a remaining clash. Both fail without the fix.

Enum type names were built from the demodulized model name, so
Course::Build and Project::Build both produced BuildState and one
enum silently replaced the other. Use the full class name instead
(CourseBuildState) and warn when two enums with different values
still share a name.

BREAKING CHANGE: enum types of namespaced models are renamed.

Closes #138
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Deploying typelizer with  Cloudflare Pages  Cloudflare Pages

Latest commit: ca26a81
Status: ✅  Deploy successful!
Preview URL: https://f417d4d8.typelizer.pages.dev
Branch Preview URL: https://fix-namespaced-enum-names.typelizer.pages.dev

View logs

@skryukov
skryukov merged commit d3708e1 into main Nov 16, 2026
9 checks passed
@skryukov
skryukov deleted the fix/namespaced-enum-names branch November 16, 2026 20:16
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.

Enum type names collide for namespaced models (demodulize drops the namespace)

1 participant