{"id":13481295,"url":"https://github.com/shuhei/babel-plugin-angular2-annotations","last_synced_at":"2025-09-25T02:31:41.058Z","repository":{"id":29883714,"uuid":"33429079","full_name":"shuhei/babel-plugin-angular2-annotations","owner":"shuhei","description":"A babel transformer plugin for Angular 2 annotations","archived":false,"fork":false,"pushed_at":"2016-12-31T10:56:15.000Z","size":78,"stargazers_count":80,"open_issues_count":3,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-11T14:44:53.128Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shuhei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-05T03:29:43.000Z","updated_at":"2020-01-02T17:54:22.000Z","dependencies_parsed_at":"2022-08-03T15:12:39.330Z","dependency_job_id":null,"html_url":"https://github.com/shuhei/babel-plugin-angular2-annotations","commit_stats":null,"previous_names":["shuhei/babel-plugin-angular2-at-annotation"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuhei%2Fbabel-plugin-angular2-annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuhei%2Fbabel-plugin-angular2-annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuhei%2Fbabel-plugin-angular2-annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuhei%2Fbabel-plugin-angular2-annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuhei","download_url":"https://codeload.github.com/shuhei/babel-plugin-angular2-annotations/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234147881,"owners_count":18786934,"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","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":[],"created_at":"2024-07-31T17:00:50.552Z","updated_at":"2025-09-25T02:31:40.724Z","avatar_url":"https://github.com/shuhei.png","language":"JavaScript","readme":"[![build status](https://img.shields.io/travis/shuhei/babel-plugin-angular2-annotations/master.svg)](https://travis-ci.org/shuhei/babel-plugin-angular2-annotations)\n[![npm version](https://img.shields.io/npm/v/babel-plugin-angular2-annotations.svg)](https://www.npmjs.org/package/babel-plugin-angular2-annotations)\n[![npm downloads](https://img.shields.io/npm/dm/babel-plugin-angular2-annotations.svg)](https://www.npmjs.org/package/babel-plugin-angular2-annotations)\n\n# babel-plugin-angular2-annotations\n\nA babel transformer plugin for Angular 2 decorators and type annotations.\n\nUse [babel-plugin-transform-decorators-legacy](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy) to support decorators.\n\n## Supported decorators/annotations\n\n### Even without this plugin (thanks to [babel-plugin-transform-decorators-legacy](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy))\n\n- Class decorators\n\n  ```js\n  @Component({ selector: 'hello' })\n  class HelloComponent {}\n  ```\n\n- Class property decorators with initializers\n\n  ```js\n  @Component({ /* ... */ })\n  class HelloComponent {\n    @Output() foo = new EventEmitter();\n  }\n  ```\n\n### With this plugin\n\n- Type annotations for constructor parameters\n\n  ```js\n  class Hello {\n    constructor(foo: Foo, bar: Bar) {\n      this.foo = foo;\n      this.bar = bar;\n    }\n  }\n  ```\n\n  - Generic types are ignored as same as in TypeScript e.g. `QueryList\u003cRouterLink\u003e` is treated as `QueryList`\n\n- Class property decorators with no initializer\n\n  ```js\n  @Component({ /* ... */ })\n  class HelloComponent {\n    @Input() bar;\n  }\n  ```\n\n- Decorators for constructor parameters\n\n  ```js\n  @Component({ /* ... */ })\n  class HelloComponent {\n    constructor(@Attribute('name') name, @Optional() optional) {\n      this.name = name;\n      this.optional = optional;\n    }\n  }\n  ```\n\n## Install\n\n```sh\nnpm install --save-dev babel-plugin-angular2-annotations\n```\n\n```sh\nnpm install --save-dev babel-plugin-transform-decorators-legacy babel-plugin-transform-class-properties babel-plugin-transform-flow-strip-types babel-preset-es2015\n```\n\n.babelrc\n\n```json\n{\n  \"plugins\": [\n    \"angular2-annotations\",\n    \"transform-decorators-legacy\",\n    \"transform-class-properties\",\n    \"transform-flow-strip-types\"\n  ],\n  \"presets\": [\n    \"es2015\"\n  ]\n}\n```\n\n## Example\n\nBefore:\n\n```js\nclass HelloComponent {\n  @Input() baz;\n  constructor(foo: Foo, @Optional() bar: Bar) {\n  }\n}\n```\n\nAfter:\n\n```js\nclass HelloComponent {\n  @Input() baz = this.baz;\n}\n\nOptional()(HelloComponent, null, 1);\nReflect.defineMetadata('design:paramtypes', [Foo, Bar]);\n```\n\nSee [babel-angular2-app](https://github.com/shuhei/babel-angular2-app) or [angular2-esnext-starter](https://github.com/blacksonic/angular2-esnext-starter) for more complete example.\n\n## License\n\n[ISC](https://opensource.org/licenses/ISC)\n","funding_links":[],"categories":["Awesome Angular [![Awesome TipeIO](https://img.shields.io/badge/Awesome%20Angular-@TipeIO-6C6AE7.svg)](https://github.com/gdi2290/awesome-angular) [![Awesome devarchy.com](https://img.shields.io/badge/Awesome%20Angular-@devarchy.com-86BDC1.svg)](https://github.com/brillout/awesome-angular-components)","Uncategorized"],"sub_categories":["Angular \u003ca id=\"angular\"\u003e\u003c/a\u003e","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuhei%2Fbabel-plugin-angular2-annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuhei%2Fbabel-plugin-angular2-annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuhei%2Fbabel-plugin-angular2-annotations/lists"}