File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ export const validatePath = (path): string =>
88 path . charAt ( 0 ) !== '/' ? '/' + path : path ;
99export const isNil = ( obj ) : boolean => isUndefined ( obj ) || obj === null ;
1010export const isEmpty = ( array ) : boolean => ! ( array && array . length > 0 ) ;
11+ export const isSymbol = ( fn ) : boolean => typeof fn === 'symbol' ;
Original file line number Diff line number Diff line change 99 isNil ,
1010 isUndefined ,
1111 isString ,
12+ isSymbol ,
1213} from '@nestjs/common/utils/shared.utils' ;
1314import { RuntimeException } from '../errors/exceptions/runtime.exception' ;
1415import { Reflector } from '../services/reflector.service' ;
@@ -255,7 +256,7 @@ export class Module {
255256 exportedComponent : CustomFactory | CustomValue | CustomClass ,
256257 ) {
257258 const provide = exportedComponent . provide ;
258- if ( isString ( provide ) ) {
259+ if ( isString ( provide ) || isSymbol ( provide ) ) {
259260 return this . _exports . add ( provide ) ;
260261 }
261262 this . _exports . add ( provide . name ) ;
Original file line number Diff line number Diff line change @@ -222,6 +222,16 @@ describe('Module', () => {
222222 module . addExportedComponent ( { provide : 'test' } as any ) ;
223223 expect ( addCustomExportedComponentSpy . called ) . to . be . true ;
224224 } ) ;
225+ it ( 'should support symbols' , ( ) => {
226+ const addCustomExportedComponentSpy = sinon . spy (
227+ module ,
228+ 'addCustomExportedComponent' ,
229+ ) ;
230+ const symb = Symbol ( 'test' ) ;
231+ module . addExportedComponent ( { provide : symb } as any ) ;
232+ expect ( addCustomExportedComponentSpy . called ) . to . be . true ;
233+ expect ( ( module as any ) . _exports . has ( symb ) ) . to . be . true ;
234+ } ) ;
225235 } ) ;
226236
227237 describe ( 'replace' , ( ) => {
You can’t perform that action at this time.
0 commit comments