An open API service indexing awesome lists of open source software.

https://github.com/unlight/inject-compile-time

Play with Custom Transformer for Typescript that enables compile-time Dependency Injection
https://github.com/unlight/inject-compile-time

Last synced: 10 months ago
JSON representation

Play with Custom Transformer for Typescript that enables compile-time Dependency Injection

Awesome Lists containing this project

README

          

## Peers
- https://github.com/YePpHa/ts-di-transformer
- https://github.com/wessberg/DI

## https://github.com/YePpHa/ts-di-transformer

```sh
npx webpack && node dist/main.js
```

```ts
class App {
constructor(todo) {
this._todo = todo;
}
}

bootstrap.resolve(app_1.App, [Symbol.for("ITodoService#0978228a")]);
```

### Pros/cons
[-] Do not enable `transpileOnly` - will not work
[+] Maybe better for NestJS
```ts
@Module({
imports: [],
controllers: [AppController],
providers: [
{
provide: InterfaceSymbol(),
useClass: TodoService,
},
],
})
export class AppController {
constructor(@Inject(InterfaceSymbol()) private readonly todoService: ITodoService) { }
}
```

## https://github.com/wessberg/di-compiler
```sh
npx webpack && node dist/bundle.js
```

```ts
class App {
constructor(todo) {
this._todo = todo;
}
static get [Symbol.for("___CTOR_ARGS___")]() { return [`ITodoService`]; }
}
```

## Resouces
- https://github.com/TypeStrong/ts-node#third-party-compilers
- https://github.com/nonara/ts-patch#configuring