File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { PARAMTYPES_METADATA } from '../../constants' ;
22
3- export function flatten < T extends any [ ] = any , R extends any [ ] = any > (
3+ export function flatten < T extends Array < unknown > = any > (
44 arr : T ,
5- ) : R {
5+ ) : T extends Array < infer R > ? R : never {
66 const flat = [ ] . concat ( ...arr ) ;
7- return ( flat . some ( Array . isArray ) ? flatten ( flat ) : flat ) as R ;
7+ return flat . some ( Array . isArray ) ? flatten ( flat ) : flat ;
88}
99
10- export const Dependencies = ( ...dependencies : any [ ] ) : ClassDecorator => {
10+ export const Dependencies = (
11+ ...dependencies : Array < unknown >
12+ ) : ClassDecorator => {
1113 const flattenDeps = flatten ( dependencies ) ;
1214 return ( target : object ) => {
1315 Reflect . defineMetadata ( PARAMTYPES_METADATA , flattenDeps , target ) ;
Original file line number Diff line number Diff line change 11import { flatten , Injectable } from '@nestjs/common' ;
2+ import { InstanceWrapper } from '../injector/instance-wrapper' ;
23import { Module } from '../injector/module' ;
34import { ModulesContainer } from '../injector/modules-container' ;
45
@@ -13,15 +14,15 @@ export class DiscoveryService {
1314 getProviders (
1415 options : DiscoveryOptions = { } ,
1516 modules : Module [ ] = this . getModules ( options ) ,
16- ) {
17+ ) : InstanceWrapper [ ] {
1718 const providers = modules . map ( item => [ ...item . providers . values ( ) ] ) ;
1819 return flatten ( providers ) ;
1920 }
2021
2122 getControllers (
2223 options : DiscoveryOptions = { } ,
2324 modules : Module [ ] = this . getModules ( options ) ,
24- ) {
25+ ) : InstanceWrapper [ ] {
2526 const controllers = modules . map ( item => [ ...item . controllers . values ( ) ] ) ;
2627 return flatten ( controllers ) ;
2728 }
You can’t perform that action at this time.
0 commit comments