Hierarchical dependency injection framework

Adapted from this experiment:
https://stackblitz.com/edit/vitejs-vite-6tenu8?file=src%2Fapp.ts
This commit is contained in:
Danny McGee
2023-12-05 17:21:43 -05:00
parent cba70a62ae
commit b2ed422d14
9 changed files with 334 additions and 21 deletions
+16
View File
@@ -1,7 +1,23 @@
export interface Ctor<T, Args extends any[] = any[]> {
new (...args: Args): T;
prototype: T;
}
export type AbstractCtor<T, Args extends any[] = any[]>
= (abstract new (...args: Args) => T)
& { prototype: T }
;
export interface Fn<Args extends any[] = [], R = void> {
(...args: Args): R;
}
export interface Method<T, Args extends any[] = any[], R = any> {
(this: T, ...args: Args): R;
}
export type Opt<T> = T | null | undefined;
export type WithOpt<T, K extends keyof T>
= Omit<T, K>
& Partial<Pick<T, K>>