Add Typedoc support and improve documentation

Upgraded the package version to 0.0.9. Introduced Typedoc for generating documentation with added script in package.json. Enhanced exception handling by introducing `DependencyResolutionError`. Refined TSinjex comments and README structure for better readability. Updated index file exports for better module organization.
This commit is contained in:
2024-08-15 17:57:07 +02:00
parent f0d1db6fa1
commit b9a75a36f5
7 changed files with 189 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
import { ImplementsStatic } from './helper/ImplementsStatic';
import { DependencyResolutionError } from './interfaces/Exceptions';
import { IDependency } from './interfaces/IDependency';
import { ITSinjex, ITSinjex_ } from './interfaces/ITSinjex';
@@ -31,7 +32,7 @@ export class TSinjex implements ITSinjex {
/**
* @inheritdoc
* @see {@link ITSInjexRegister.register}
* @see {@link ITSinjex.register}
*/
public static register<T>(
identifier: string,
@@ -46,7 +47,7 @@ export class TSinjex implements ITSinjex {
/**
* @inheritdoc
* @see {@link ITSInjexResolve.resolve}
* @see {@link ITSinjex.resolve}
*/
public static resolve<T>(
identifier: string,
@@ -83,7 +84,7 @@ export class TSinjex implements ITSinjex {
const dependency = this._dependencies.get(identifier);
if (necessary && !dependency) {
throw new Error(`Dependency ${identifier} not found`);
throw new DependencyResolutionError(identifier);
} else if (!dependency) {
return undefined;
}

View File

@@ -1,5 +1,6 @@
/**
* Decorator to enforce static implementation of an interface
* Decorator to enforce static implementation of an interface.
* Warns on compile time if the interface is not implemented.
* @returns A decorator function
*/
export function ImplementsStatic<I>() {

View File

@@ -1,9 +1,16 @@
// Main
export * from './TSinjex';
// Decorators
export * from './decorators/Inject';
export * from './decorators/Register';
export * from './decorators/RegisterInstance';
// Functions
export * from './functions/resolve';
export * from './functions/register';
// Interfaces & Types
export type * from './interfaces/ITSinjex';
export type * from './types/InitDelegate';
export type * from './types/GenericContructor';