Skip to content

feature: ts enum generation improvements - #195

Merged
joshmossas merged 7 commits into
masterfrom
feature/ts-enum-generation
May 21, 2026
Merged

feature: ts enum generation improvements#195
joshmossas merged 7 commits into
masterfrom
feature/ts-enum-generation

Conversation

@joshmossas

@joshmossas joshmossas commented May 21, 2026

Copy link
Copy Markdown
Member

Make TS codegen output a const enum object in addition to the enum type like so:

export type MyEnum = "foo" | "bar" | "baz";
// this block now appears in the generated output
export const MyEnum = {
  Foo: "foo",
  Bar: "bar",
  Baz: "baz"
} as const;
const $$MyEnumValues = ["foo", "bar", "baz"] as const;

This allows you to use either the string value or the "enum" style object:

function doThingWithEnum(input: MyEnum) {
 // todo
}

doThingWithEnum("foo");
doThingWithEnum(MyEnum.Foo);

@nx-cloud

nx-cloud Bot commented May 21, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 3eaadd8

Command Status Duration Result
nx build-server test-server-go --configuration=... ✅ Succeeded 8s View ↗
nx build-server test-server-ts --configuration=... ✅ Succeeded 5s View ↗
nx affected -t test --configuration windows-ci ✅ Succeeded 2m 25s View ↗
nx build-server test-server-go ✅ Succeeded 5s View ↗
nx build-server test-server-ts ✅ Succeeded 3s View ↗
nx affected -t test ✅ Succeeded 1m 53s View ↗
nx run-many -t compile ✅ Succeeded 4m 26s View ↗
nx run-many -t compile --configuration windows-ci ✅ Succeeded 2m 27s View ↗
Additional runs (7) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2026-05-21 17:59:14 UTC

@joshmossas
joshmossas merged commit ebd3d40 into master May 21, 2026
5 checks passed
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.

1 participant