-
Notifications
You must be signed in to change notification settings - Fork 2
Doctor Dose
GitHub Actions edited this page Aug 15, 2026
·
2 revisions
Property decorator that marks a field as a dependency for Doctor to fill in.
class MyHandler {
@Dose()
public logger!: Logger;
}@Dose reads the property's runtime type from reflect-metadata's
design:type slot and appends an entry to the class's
design:injectable array. Injection happens later, when
@Inoculate (or a manual Doctor.treat(this)) walks that
array.
- The consumer's TypeScript config must have
emitDecoratorMetadata: true— otherwisedesign:typewill beundefinedand@DosethrowsMissingDesignTypeError. -
reflect-metadatamust be imported once at the entry point — otherwise@DosethrowsMissingMetadataError.
@Inoculate()
class UserHandler {
@Dose()
public logger!: Logger;
@Dose()
public db!: Database;
}-
MissingMetadataError— whenreflect-metadatais unavailable. -
MissingDesignTypeError— whenemitDecoratorMetadataisn't enabled.
Every class in the web-app example uses
@Dose — see Database.ts for
multi-property injection or
UserHandler.ts for a plain
class that's wired up via Doctor.resolve instead of @Inoculate.