Skip to content

Commit

Permalink
fix: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
CGQAQ committed Dec 2, 2024
1 parent 1a0047f commit 4a82216
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/base/common/instantiation/instantiation.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { type interfaces, LazyServiceIdentifer } from 'inversify';
import { type interfaces, LazyServiceIdentifier } from 'inversify';

export type Newable<T> = interfaces.Newable<T>;

export type ServiceIdentifier<T> = interfaces.ServiceIdentifier<T>;

export type FactoryFunction<T> = () => interfaces.ServiceIdentifier<T>;

export type ServiceDescriptor<T> = T | LazyServiceIdentifer<T> | FactoryFunction<T>;
export type ServiceDescriptor<T> = T | LazyServiceIdentifier<T> | FactoryFunction<T>;

export { LazyServiceIdentifer };
export { LazyServiceIdentifier };

export interface ServicesAccessor {
get<T>(id: ServiceIdentifier<T>): T;
}

const _registry: [ServiceIdentifier<unknown>, ServiceDescriptor<unknown>][] = [];

export function registerSingleton<T>(id: ServiceIdentifier<T>, useValue: T | LazyServiceIdentifer<T>): void;
export function registerSingleton<T>(id: ServiceIdentifier<T>, useValue: T | LazyServiceIdentifier<T>): void;
export function registerSingleton<T>(id: ServiceIdentifier<T>, useFactory: FactoryFunction<T>): void;
export function registerSingleton<T>(
id: ServiceIdentifier<T>,
Expand All @@ -25,16 +25,16 @@ export function registerSingleton<T>(
): void;
export function registerSingleton<T>(
id: ServiceIdentifier<T>,
ctorOrDescriptor: T | LazyServiceIdentifer<T> | Newable<T> | FactoryFunction<T>,
ctorOrDescriptor: T | LazyServiceIdentifier<T> | Newable<T> | FactoryFunction<T>,
supportsDelayedInstantiation?: boolean,
): void {
if (ctorOrDescriptor instanceof LazyServiceIdentifer) {
if (ctorOrDescriptor instanceof LazyServiceIdentifier) {
_registry.push([id, ctorOrDescriptor]);
return;
}

if (typeof ctorOrDescriptor === 'function' && supportsDelayedInstantiation) {
_registry.push([id, new LazyServiceIdentifer<T>(() => ctorOrDescriptor as Newable<T>)]);
_registry.push([id, new LazyServiceIdentifier<T>(() => ctorOrDescriptor as Newable<T>)]);
return;
}

Expand Down
9 changes: 6 additions & 3 deletions src/base/common/instantiation/instantiationService.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Container, type interfaces, LazyServiceIdentifer } from 'inversify';
import { Container, type interfaces, LazyServiceIdentifier } from 'inversify';



import { isDisposable } from '../lifecycle';
import { getSingletonServiceDescriptors, type ServiceIdentifier } from './instantiation';


export const providerContainer = new Container();

export class InstantiationService {
Expand All @@ -13,7 +16,7 @@ export class InstantiationService {
for (const [identifier, descriptor] of getSingletonServiceDescriptors()) {
const binding = providerContainer.bind(identifier);

if (descriptor instanceof LazyServiceIdentifer) {
if (descriptor instanceof LazyServiceIdentifier) {
binding.toDynamicValue(() => descriptor.unwrap()).inSingletonScope();
} else {
binding.toConstantValue(descriptor);
Expand Down Expand Up @@ -104,4 +107,4 @@ export class InstantiationService {
throw new Error('InstantiationService has been disposed');
}
}
}
}

0 comments on commit 4a82216

Please sign in to comment.