Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yrtimid/angularjs-ts-class-annotate
AngularJS Typescript class-only annotation library
https://github.com/yrtimid/angularjs-ts-class-annotate
angularjs annotate nodejs typescript
Last synced: 15 days ago
JSON representation
AngularJS Typescript class-only annotation library
- Host: GitHub
- URL: https://github.com/yrtimid/angularjs-ts-class-annotate
- Owner: yrtimiD
- License: mit
- Created: 2020-03-15T11:22:16.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-02T22:55:56.000Z (over 1 year ago)
- Last Synced: 2024-12-17T03:38:15.313Z (19 days ago)
- Topics: angularjs, annotate, nodejs, typescript
- Language: TypeScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# angularjs-ts-class-annotate
Adds AngularJS dependency annotations for typescript classes## Important notes
* Supports typescript classes only.
* Adds AngularJS $inject statement for constructors in all classes regardless if they are registered in the angular injector or not.
* Existing $inject statements are totally ignored.## Usage example
```sh
npm install angularjs-ts-class-annotate
```
[typescript](https://www.npmjs.com/package/typescript) is a peer dependency, make sure to install it (tested with v3 only):
```sh
npm install typescript@3
```and run:
```js
const fs = require("fs");
const annotateTs = require("angularjs-ts-class-annotate");var fileContent = fs.readFileSync("some-class.ts", "utf8");
fileContent = annotateTs(fileContent);
fs.writeFileSync("some-class.annotated.ts", fileContent, "utf8");
```### Before: original some-class.ts
```typescript
class Class1 {
constructor(private $log: ng.ILogService, private $window: ng.IWindowService) {
}
}
```
### After: annotated some-class.annotated.ts
```typescript
class Class1 {
static $inject = ["$log","$window"];
constructor(private $log: ng.ILogService, private $window: ng.IWindowService) {
}
}
```## Building
```
npm i
npm run build
npm run demo
```