Skip to content

Commit d76040b

Browse files
fix(core): the default distance should be 1 nestjs#7582
1 parent add7eef commit d76040b

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

packages/core/scanner.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ interface ApplicationProviderWrapper {
5454
}
5555

5656
export class DependenciesScanner {
57-
private readonly applicationProvidersApplyMap: ApplicationProviderWrapper[] = [];
57+
private readonly applicationProvidersApplyMap: ApplicationProviderWrapper[] =
58+
[];
5859

5960
constructor(
6061
private readonly container: NestContainer,
@@ -255,10 +256,9 @@ export class DependenciesScanner {
255256
component.prototype,
256257
method => Reflect.getMetadata(metadataKey, component, method),
257258
);
258-
const paramsInjectables = this.flatten(
259-
paramsMetadata,
260-
).map((param: Record<string, any>) =>
261-
flatten(Object.keys(param).map(k => param[k].pipes)).filter(isFunction),
259+
const paramsInjectables = this.flatten(paramsMetadata).map(
260+
(param: Record<string, any>) =>
261+
flatten(Object.keys(param).map(k => param[k].pipes)).filter(isFunction),
262262
);
263263
flatten(paramsInjectables).forEach((injectable: Type<Injectable>) =>
264264
this.insertInjectable(injectable, token, component),
@@ -292,7 +292,7 @@ export class DependenciesScanner {
292292
modulesGenerator.next();
293293

294294
const modulesStack = [];
295-
const calculateDistance = (moduleRef: Module, distance = 0) => {
295+
const calculateDistance = (moduleRef: Module, distance = 1) => {
296296
if (modulesStack.includes(moduleRef)) {
297297
return;
298298
}
@@ -336,11 +336,13 @@ export class DependenciesScanner {
336336
}
337337
const applyProvidersMap = this.getApplyProvidersMap();
338338
const providersKeys = Object.keys(applyProvidersMap);
339-
const type = (provider as
340-
| ClassProvider
341-
| ValueProvider
342-
| FactoryProvider
343-
| ExistingProvider).provide;
339+
const type = (
340+
provider as
341+
| ClassProvider
342+
| ValueProvider
343+
| FactoryProvider
344+
| ExistingProvider
345+
).provide;
344346

345347
if (!providersKeys.includes(type as string)) {
346348
return this.container.addProvider(provider as any, token);

0 commit comments

Comments
 (0)