@@ -10,7 +10,7 @@ import { Module } from '../injector/module';
1010 * Returns the name of an instance
1111 * @param instance The instance which should get the name from
1212 */
13- const getInstanceName = ( instance : unknown ) =>
13+ const getInstanceName = ( instance : unknown ) : string =>
1414 instance && ( instance as Type < any > ) . name ;
1515
1616/**
@@ -19,13 +19,13 @@ const getInstanceName = (instance: unknown) =>
1919 * (= injection token). As fallback it returns '+'
2020 * @param dependency The dependency whichs name should get displayed
2121 */
22- const getDependencyName = ( dependency : InjectorDependency ) =>
22+ const getDependencyName = ( dependency : InjectorDependency ) : string =>
2323 // use class name
2424 getInstanceName ( dependency ) ||
2525 // use injection token (symbol)
2626 ( isSymbol ( dependency ) && dependency . toString ( ) ) ||
2727 // use string directly
28- dependency ||
28+ ( dependency as string ) ||
2929 // otherwise
3030 '+' ;
3131
@@ -49,15 +49,16 @@ export const UNKNOWN_DEPENDENCIES_MESSAGE = (
4949 key,
5050 } = unknownDependencyContext ;
5151 const moduleName = getModuleName ( module ) || 'Module' ;
52+ const dependencyName = getDependencyName ( name ) ;
5253
5354 let message = `Nest can't resolve dependencies of the ${ type . toString ( ) } ` ;
5455
5556 const potentialSolutions = `\n
5657Potential solutions:
57- - If ${ name } is a provider, is it part of the current ${ moduleName } ?
58- - If ${ name } is exported from a separate @Module, is that module imported within ${ moduleName } ?
58+ - If ${ dependencyName } is a provider, is it part of the current ${ moduleName } ?
59+ - If ${ dependencyName } is exported from a separate @Module, is that module imported within ${ moduleName } ?
5960 @Module({
60- imports: [ /* the Module containing ${ name } */ ]
61+ imports: [ /* the Module containing ${ dependencyName } */ ]
6162 })
6263` ;
6364
@@ -70,7 +71,7 @@ Potential solutions:
7071
7172 message += ` (` ;
7273 message += dependenciesName . join ( ', ' ) ;
73- message += `). Please make sure that the argument ${ name } at index [${ index } ] is available in the ${ getModuleName (
74+ message += `). Please make sure that the argument ${ dependencyName } at index [${ index } ] is available in the ${ getModuleName (
7475 module ,
7576 ) } context.`;
7677 message += potentialSolutions ;
0 commit comments