Models unit; session model; generalize session classes/interfaces

This commit is contained in:
garrettmills
2020-07-27 09:41:04 -05:00
parent 878de025d8
commit 25a37cf1a2
27 changed files with 331 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
import Instantiable from './Instantiable.ts'
import {StaticClass} from './StaticClass.ts'
const DEPENDENCY_KEYS_METADATA_KEY = 'daton:di:dependencyKeys.ts'
type DependencyKey = Instantiable<any> | StaticClass<any> | string
type DependencyKey = Instantiable<any> | StaticClass<any, any> | string
export { DependencyKey, DEPENDENCY_KEYS_METADATA_KEY }

View File

@@ -2,7 +2,7 @@ export default interface Instantiable<T> {
new(...args: any[]): T
}
const isInstantiable = (what: any): what is Instantiable<any> => {
const isInstantiable = <T>(what: any): what is Instantiable<T> => {
return (typeof what === 'object' || typeof what === 'function') && 'constructor' in what && typeof what.constructor === 'function'
}

View File

@@ -1,5 +1,5 @@
export type StaticClass<T> = Function & {prototype: T}
export type StaticClass<T, T2> = Function & {prototype: T} & T2
export function isStaticClass<T>(something: any): something is StaticClass<T> {
export function isStaticClass<T, T2>(something: any): something is StaticClass<T, T2> {
return typeof something === 'function' && typeof something.prototype !== 'undefined'
}