11import { Type } from '@nestjs/common' ;
2- import { isNil } from '@nestjs/common/utils/shared.utils' ;
3- import { InjectorDependency , InjectorDependencyContext } from '../injector/injector' ;
2+ import { isNil , isSymbol } from '@nestjs/common/utils/shared.utils' ;
3+ import {
4+ InjectorDependency ,
5+ InjectorDependencyContext ,
6+ } from '../injector/injector' ;
47import { Module } from '../injector/module' ;
58
69// TODO: Replace `any` with `unknown` type when TS 3.0.0 is supported
@@ -18,7 +21,15 @@ const getInstanceName = (instance: unknown) =>
1821 * @param dependency The dependency whichs name should get displayed
1922 */
2023const getDependencyName = ( dependency : InjectorDependency ) =>
21- getInstanceName ( dependency ) || dependency || '+' ;
24+ // use class name
25+ getInstanceName ( dependency ) ||
26+ // use injection token (symbol)
27+ ( isSymbol ( dependency ) && dependency . toString ( ) ) ||
28+ // use string directly
29+ dependency ||
30+ // otherwise
31+ '+' ;
32+
2233/**
2334 * Returns the name of the module
2435 * Tries to get the class name. As fallback it returns 'current'.
@@ -28,15 +39,15 @@ const getModuleName = (module: Module) =>
2839 ( module && getInstanceName ( module . metatype ) ) || 'current' ;
2940
3041export const UNKNOWN_DEPENDENCIES_MESSAGE = (
31- type : string ,
42+ type : string | symbol ,
3243 unknownDependencyContext : InjectorDependencyContext ,
3344 module : Module ,
3445) => {
3546 const { index, dependencies, key } = unknownDependencyContext ;
36- let message = `Nest can't resolve dependencies of the ${ type } ` ;
47+ let message = `Nest can't resolve dependencies of the ${ type . toString ( ) } ` ;
3748
3849 if ( isNil ( index ) ) {
39- message += `. Please make sure that the "${ key } " property is available in the current context.` ;
50+ message += `. Please make sure that the "${ key . toString ( ) } " property is available in the current context.` ;
4051 return message ;
4152 }
4253 const dependenciesName = ( dependencies || [ ] ) . map ( getDependencyName ) ;
0 commit comments