Skip to content

Commit

Permalink
Remove internal ResolutionStack from library external interface
Browse files Browse the repository at this point in the history
  • Loading branch information
fnimick committed Jan 2, 2024
1 parent 258476e commit 31c4649
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
20 changes: 7 additions & 13 deletions src/container.ts
Expand Up @@ -5,7 +5,7 @@ import {
AwilixTypeError,
} from './errors'
import { InjectionMode, InjectionModeType } from './injection-mode'
import { Lifetime, LifetimeType, isLifetimeLonger } from './lifetime'
import { Lifetime, isLifetimeLonger } from './lifetime'
import { GlobWithOptions, listModules } from './list-modules'
import { importModule } from './load-module-native.js'
import {
Expand All @@ -21,7 +21,7 @@ import {
asClass,
asFunction,
} from './resolvers'
import { ResolverInternal } from './types'
import { ResolutionStack, ResolverInternal } from './types'
import { isClass, last, nameValueToObject } from './utils'

/**
Expand Down Expand Up @@ -207,12 +207,6 @@ export type RegistrationHash = Record<
ResolverInternal<any>
>

/**
* Resolution stack.
*/
export interface ResolutionStack
extends Array<{ name: string | symbol; lifetime: LifetimeType }> {}

/**
* Family tree symbol.
*/
Expand Down Expand Up @@ -251,10 +245,10 @@ export function createContainer<T extends object = any, U extends object = any>(
...options,
}

// The resolution stack is used to keep track
// of what modules are being resolved, so when
// an error occurs, we have something to present
// to the poor developer who fucked up.
/**
* Tracks the names and lifetimes of the modules being resolved. Used to detect circular
* dependencies and, in strict mode, lifetime leakage issues.
*/
let resolutionStack: ResolutionStack = []

// Internal registration store for this container.
Expand Down Expand Up @@ -627,7 +621,7 @@ export function createContainer<T extends object = any, U extends object = any>(
* Does not cache it, this means that any lifetime configured in case of passing
* a registration will not be used.
*
* @param {Resolver|Class|Function} targetOrResolver
* @param {Resolver|Constructor|Function} targetOrResolver
* @param {ResolverOptions} opts
*/
function build<T>(
Expand Down
2 changes: 1 addition & 1 deletion src/errors.ts
@@ -1,4 +1,4 @@
import { ResolutionStack } from './container'
import { ResolutionStack } from './types'

/**
* Newline.
Expand Down
4 changes: 2 additions & 2 deletions src/resolvers.ts
Expand Up @@ -239,7 +239,7 @@ export function aliasTo<T>(
* @return {object}
* The interface.
*/
export function createBuildResolver<T, B extends Resolver<T>>(
function createBuildResolver<T, B extends Resolver<T>>(
obj: B,
): BuildResolver<T> & B {
function setLifetime(this: any, value: LifetimeType) {
Expand Down Expand Up @@ -280,7 +280,7 @@ export function createBuildResolver<T, B extends Resolver<T>>(
* function.
* @param obj
*/
export function createDisposableResolver<T, B extends Resolver<T>>(
function createDisposableResolver<T, B extends Resolver<T>>(
obj: B,
): DisposableResolver<T> & B {
function disposer(this: any, dispose: Disposer<T>) {
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
@@ -1,3 +1,4 @@
import { LifetimeType } from './lifetime'
import { Resolver } from './resolvers'

export interface ResolverInternal<T> extends Resolver<T> {
Expand All @@ -14,3 +15,6 @@ export interface ResolverInternal<T> extends Resolver<T> {
*/
isLeakSafe?: boolean
}

export interface ResolutionStack
extends Array<{ name: string | symbol; lifetime: LifetimeType }> {}

0 comments on commit 31c4649

Please sign in to comment.