{"id":36667774,"url":"https://github.com/jiftechnify/eject-enum","last_synced_at":"2026-01-12T10:36:59.416Z","repository":{"id":41284655,"uuid":"509024476","full_name":"jiftechnify/eject-enum","owner":"jiftechnify","description":"Eject enums from your TypeScript codebase.","archived":false,"fork":false,"pushed_at":"2025-12-20T14:44:39.000Z","size":581,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-21T23:32:34.352Z","etag":null,"topics":["rewriting","typescript"],"latest_commit_sha":null,"homepage":"https://jiftechnify.github.io/eject-enum","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiftechnify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-06-30T09:55:02.000Z","updated_at":"2025-12-21T08:23:29.000Z","dependencies_parsed_at":"2023-02-13T01:16:24.300Z","dependency_job_id":null,"html_url":"https://github.com/jiftechnify/eject-enum","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/jiftechnify/eject-enum","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiftechnify%2Feject-enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiftechnify%2Feject-enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiftechnify%2Feject-enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiftechnify%2Feject-enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiftechnify","download_url":"https://codeload.github.com/jiftechnify/eject-enum/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiftechnify%2Feject-enum/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T06:09:07.588Z","status":"ssl_error","status_checked_at":"2026-01-12T06:05:18.301Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rewriting","typescript"],"created_at":"2026-01-12T10:36:58.259Z","updated_at":"2026-01-12T10:36:59.403Z","avatar_url":"https://github.com/jiftechnify.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eject-enum\n\nEject `enum`s from your TypeScript codebase.\n\n## What is this?\n\n**eject-enum** is a code rewriting tool for TypeScript codebases that\nrewrites each TypeScript `enum` in your codebase to\n[the safer alternative](https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums).\n\n**Before rewriting**:\n\n```ts\n/**\n * Signals of traffic light.\n */\nexport enum TrafficLight {\n    /** Stop. */\n    Red,\n    /** Stop unless you can't do so safely. */\n    Yellow,\n    /** Go. */\n    Green,\n}\n```\n\n**After rewriting**:\n\n```ts\n/**\n * Signals of traffic light.\n */\nexport const TrafficLight = {\n    /** Stop. */\n    Red: 0,\n    /** Stop unless you can't do so safely. */\n    Yellow: 1,\n    /** Go. */\n    Green: 2,\n} as const;\n\nexport type TrafficLight = (typeof TrafficLight)[keyof typeof TrafficLight];\n```\n\n## Usage\n\n\u003e [!Note]\n\u003e \n\u003e **It is recommended to run code formatting tools after rewriting by\n\u003e eject-enum**, as it doesn't consider any code formatting configurations of\n\u003e your project when rewriting.\n\n### As a CLI\n\nYou can execute **eject-enum** as a CLI tool:\n\n```bash\n# npm\nnpx eject-enum [options...]\n\n# pnpm\npnpx eject-enum [options...]\n\n# Bun\nbunx eject-enum [options...]\n\n# Deno \u003e=2.6 (cf. https://deno.com/blog/v2.6#run-package-binaries-with-dx)\ndx eject-enum [options...]\n```\n\nCLI Options:\n\n```bash\n# If no targets are specified, it tries to use `tsconfig.json` \n# in the current directory as the default target.\nnpx eject-enum\n\n# Rewrite all files in projects specified by tsconfigs.\nnpx eject-enum path/to/tsconfig.json path/to/tsconfig2.json\n\n# Rewrite all Typescript files under the `src` and `test` directories,\n# except files under the `src/foo` directory.\nnpx eject-enum \"src/**/*.ts\" \"test/**/*.ts\" --exclude \"src/foo/**/*.ts\"\n```\n\n### As a Library\n\nYou can use **eject-enum** as a library from your scripts as well.\n\n```bash\nnpm install --save-dev eject-enum\n```\n\n```ts\nimport { ejectEnum, EjectEnumTarget } from \"eject-enum\";\n\n// Rewrite all files in projects specified by paths to tsconfigs.\nejectEnum(\n    EjectEnumTarget.projects([\n        \"path/to/tsconfig.json\",\n        \"path/to/tsconfig2.json\",\n    ]),\n);\n\n// Rewrite all Typescript files under the `src` and `test` directories\n// except files under the `src/foo` directory.\nejectEnum(\n    EjectEnumTarget.srcPaths({\n        include: [\"src/**/*.ts\", \"test/**/*.ts\"],\n        exclude: [\"src/foo/**/*.ts\"],\n    }),\n);\n```\n\n## Features\n\n- [x] Rewrite enums in the top-level as well as nested in functions, namespaces\n      and body of control flows (`if`, `while`, `switch`).\n- [x] Rewrite enums that have\n      [constant enum expressions](https://www.typescriptlang.org/docs/handbook/enums.html#computed-and-constant-members)\n      as member's value.\n- [x] Preserve comments as much as possible.\n- [x] Preserve original expressions of enum members in the original code as\n      comments.\n- [x] Rewrite\n      [an enum member used as a type](https://www.typescriptlang.org/docs/handbook/enums.html#union-enums-and-enum-member-types).\n\n## Limitations\n\n**eject-enum** have some limitations about code rewriting. They originate from\nlimitations of the TS Compiler API/ts-morph.\n\n- Can't rewrite enums that have computed enum members.\n  - e.g. referring variables, members of other enums (even constant members)\n- Can't preserve original trailing comments of enum members.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiftechnify%2Feject-enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiftechnify%2Feject-enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiftechnify%2Feject-enum/lists"}