{"id":13679538,"url":"https://github.com/leonardfactory/babel-plugin-transform-typescript-metadata","last_synced_at":"2026-01-21T08:16:33.842Z","repository":{"id":34328110,"uuid":"177405861","full_name":"leonardfactory/babel-plugin-transform-typescript-metadata","owner":"leonardfactory","description":"Babel plugin to emit decorator metadata like typescript compiler","archived":false,"fork":false,"pushed_at":"2025-10-29T19:44:18.000Z","size":630,"stargazers_count":222,"open_issues_count":13,"forks_count":18,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-11T15:55:07.626Z","etag":null,"topics":["babel","babel-plugin","babel-typescript","decorators","reflect-metadata","typescript"],"latest_commit_sha":null,"homepage":null,"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/leonardfactory.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2019-03-24T11:32:22.000Z","updated_at":"2025-11-17T07:39:53.000Z","dependencies_parsed_at":"2024-02-04T13:07:07.592Z","dependency_job_id":"762e7ad6-b06a-4e52-950f-4c9a214be61d","html_url":"https://github.com/leonardfactory/babel-plugin-transform-typescript-metadata","commit_stats":{"total_commits":62,"total_committers":6,"mean_commits":"10.333333333333334","dds":"0.22580645161290325","last_synced_commit":"3a52ff7039e3ccf4e5a4a6b5731edbcee3048524"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/leonardfactory/babel-plugin-transform-typescript-metadata","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardfactory%2Fbabel-plugin-transform-typescript-metadata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardfactory%2Fbabel-plugin-transform-typescript-metadata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardfactory%2Fbabel-plugin-transform-typescript-metadata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardfactory%2Fbabel-plugin-transform-typescript-metadata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leonardfactory","download_url":"https://codeload.github.com/leonardfactory/babel-plugin-transform-typescript-metadata/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leonardfactory%2Fbabel-plugin-transform-typescript-metadata/sbom","scorecard":{"id":584837,"data":{"date":"2025-08-11","repo":{"name":"github.com/leonardfactory/babel-plugin-transform-typescript-metadata","commit":"3a52ff7039e3ccf4e5a4a6b5731edbcee3048524"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/leonardfactory/babel-plugin-transform-typescript-metadata/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/leonardfactory/babel-plugin-transform-typescript-metadata/test.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/leonardfactory/babel-plugin-transform-typescript-metadata/test.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Code-Review","score":2,"reason":"Found 4/14 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 22 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"60 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-h5c3-5r3r-rr8q","Warn: Project is vulnerable to: GHSA-rmvr-2pp2-xj38","Warn: Project is vulnerable to: GHSA-xx4v-prfh-6cgc","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-px4h-xg32-q955","Warn: Project is vulnerable to: GHSA-3j8f-xvm3-ffx4","Warn: Project is vulnerable to: GHSA-4p35-cfcx-8653","Warn: Project is vulnerable to: GHSA-7f3x-x4pr-wqhj","Warn: Project is vulnerable to: GHSA-jpp7-7chh-cf67","Warn: Project is vulnerable to: GHSA-q6wq-5p59-983w","Warn: Project is vulnerable to: GHSA-j9fq-vwqv-2fm2","Warn: Project is vulnerable to: GHSA-pqw5-jmp5-px4v","Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx","Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch","Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6","Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v","Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T20:10:30.878Z","repository_id":34328110,"created_at":"2025-08-20T20:10:30.878Z","updated_at":"2025-08-20T20:10:30.878Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28057911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-26T02:00:06.189Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["babel","babel-plugin","babel-typescript","decorators","reflect-metadata","typescript"],"created_at":"2024-08-02T13:01:06.620Z","updated_at":"2026-01-21T08:16:33.836Z","avatar_url":"https://github.com/leonardfactory.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","JavaScript"],"sub_categories":[],"readme":"# babel-plugin-transform-typescript-metadata\n\n![GitHub Workflow Build Status](https://img.shields.io/github/actions/workflow/status/leonardfactory/babel-plugin-transform-typescript-metadata/test.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/leonardfactory/babel-plugin-transform-typescript-metadata.svg)](https://codecov.io/gh/leonardfactory/babel-plugin-transform-typescript-metadata)\n[![npm](https://img.shields.io/npm/v/babel-plugin-transform-typescript-metadata.svg?style=popout)](https://www.npmjs.com/package/babel-plugin-transform-typescript-metadata)\n\nBabel plugin to emit decorator metadata like typescript compiler\n\n## Motivation\n\nTypeScript _Decorators_ allows advanced reflection patterns when combined\nwith [`Reflect.metadata`](https://rbuckton.github.io/reflect-metadata/) output.\n\nCurrent `@babel/preset-typescript` implementation however just strips all types and\n_does not_ emit the relative Metadata in the output code.\n\nSince this kind of information is used extensively in libraries like\n[Nest](https://docs.nestjs.com/providers) and [TypeORM](https://typeorm.io/#/)\nto implement advanced features like **Dependency Injection**, I've thought it would\nbe awesome to be able to provide the same functionality that [TypeScript\ncompiler `experimentalDecorators` and `emitDecoratorMetadata`\nflags](https://www.typescriptlang.org/docs/handbook/decorators.html) provide.\n\nThis means that code like:\n\n```ts\nimport { Injectable, Inject } from 'some-di-library'; // Just an example\nimport { MyService } from './MyService';\nimport { Configuration } from './Configuration';\n\n@Injectable()\nclass AnotherService {\n  @Inject()\n  config: Configuration;\n\n  constructor(private service: MyService) {}\n}\n```\n\nwill be interpreted like:\n\n```ts\nimport { MyService } from './MyService';\nimport { Configuration } from './Configuration';\n\n@Injectable()\n@Reflect.metadata('design:paramtypes', [MyService])\nclass AnotherService {\n  @Inject()\n  @Reflect.metadata('design:type', Configuration)\n  config: Configuration;\n\n  constructor(private service: MyService) {}\n}\n```\n\n### Parameter decorators\n\nSince decorators in typescript supports also _Parameters_, this plugin\nalso provides support for them, enabling the following syntax:\n\n```ts\n@Injectable()\nclass Some {\n  constructor(@Inject() private: SomeService);\n}\n```\n\nThis will be roughly translated to:\n\n```js\n// ...\nInject()(Some.prototype, undefined, 0);\n```\n\n## Installation\n\nWith npm:\n\n```sh\nnpm install --dev --save babel-plugin-transform-typescript-metadata\n```\n\nor with Yarn:\n\n```sh\nyarn add --dev babel-plugin-transform-typescript-metadata\n```\n\n## Usage\n\nWith `.babelrc`:\n\n\u003e **Note:** should be placed **before** `@babel/plugin-proposal-decorators`.\n\n```js\n{\n  \"plugins\": [\n    \"babel-plugin-transform-typescript-metadata\",\n    [\"@babel/plugin-proposal-decorators\", { \"legacy\": true }],\n    [\"@babel/plugin-proposal-class-properties\", { \"loose\": true }],\n  ],\n  \"presets\": [\n    \"@babel/preset-typescript\"\n  ]\n}\n```\n\n### Usage with [InversifyJS](http://inversify.io)\n\nIf you are using normal dependency injection letting Inversify **create your instances**, you should be fine with all kind of decorators.\n\nInstead, if you are using **property injection**, when [the container does not\ncreate the instances](https://github.com/inversify/InversifyJS/blob/master/wiki/property_injection.md#when-we-cannot-use-inversifyjs-to-create-an-instance-of-a-class),\nyou would likely encounter errors since babel\ndecorators are not exactly the same as TypeScript.\n\nYou can fix it by _enhancing property decorators_ with the following function:\n\n```ts\nimport getDecorators from 'inversify-inject-decorators';\n// setup the container...\nlet { lazyInject: originalLazyInject } = getDecorators(container);\n\n// Additional function to make properties decorators compatible with babel.\nfunction fixPropertyDecorator\u003cT extends Function\u003e(decorator: T): T {\n  return ((...args: any[]) =\u003e\n    (target: any, propertyName: any, ...decoratorArgs: any[]) =\u003e {\n      decorator(...args)(target, propertyName, ...decoratorArgs);\n      return Object.getOwnPropertyDescriptor(target, propertyName);\n    }) as any;\n}\n\nexport const lazyInject = fixPropertyDecorator(originalLazyInject);\n```\n\n## Current Pitfalls\n\n- If you are using webpack and it complains about missing exports due to types\n  not being removed, you can switch from `import { MyType } from ...` to\n  `import type { MyType } from ...`. See [#46](https://github.com/leonardfactory/babel-plugin-transform-typescript-metadata/issues/46) for details and\n  examples.\n\n- We cannot know if type annotations are just types (i.e. `IMyInterface`) or\n  concrete values (like classes, etc.). In order to resolve this, we emit the\n  following: `typeof Type === 'undefined' ? Object : Type`. The code has the\n  advantage of not throwing. If you know a better way to do this, let me know!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonardfactory%2Fbabel-plugin-transform-typescript-metadata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleonardfactory%2Fbabel-plugin-transform-typescript-metadata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleonardfactory%2Fbabel-plugin-transform-typescript-metadata/lists"}