@@ -9,14 +9,16 @@ const metadataKeys = [
99 metadata . EXPORTS ,
1010 metadata . COMPONENTS ,
1111 metadata . CONTROLLERS ,
12+ metadata . PROVIDERS ,
1213] ;
1314
1415const validateKeys = ( keys : string [ ] ) => {
15- const isKeyValid = key => metadataKeys . findIndex ( k => k === key ) < 0 ;
16+ const isKeyInvalid = key => metadataKeys . findIndex ( k => k === key ) < 0 ;
1617 const validateKey = key => {
17- if ( isKeyValid ( key ) ) {
18- throw new InvalidModuleConfigException ( key ) ;
18+ if ( ! isKeyInvalid ( key ) ) {
19+ return ;
1920 }
21+ throw new InvalidModuleConfigException ( key ) ;
2022 } ;
2123 keys . forEach ( validateKey ) ;
2224} ;
@@ -25,16 +27,16 @@ const validateKeys = (keys: string[]) => {
2527 * Defines the module
2628 * - `imports` - the set of the 'imported' modules
2729 * - `controllers` - the list of controllers (e.g. HTTP controllers)
28- * - `components ` - the list of components that belong to this module. They can be injected between themselves.
30+ * - `providers ` - the list of providers that belong to this module. They can be injected between themselves.
2931 * - `exports` - the set of components, which should be available for modules, which imports this module
3032 * - `modules` - @deprecated the set of the 'imported' modules
33+ * - `components` - @deprecated the list of components that belong to this module. They can be injected between themselves.
3134 * @param obj {ModuleMetadata} Module metadata
3235 */
3336export function Module ( obj : ModuleMetadata ) : ClassDecorator {
3437 const propsKeys = Object . keys ( obj ) ;
3538 validateKeys ( propsKeys ) ;
36-
37- obj . modules = obj . imports && ! obj . modules ? obj . imports : obj . modules ;
39+ overrideModuleMetadata ( obj ) ;
3840
3941 return ( target : object ) => {
4042 for ( const property in obj ) {
@@ -44,3 +46,13 @@ export function Module(obj: ModuleMetadata): ClassDecorator {
4446 }
4547 } ;
4648}
49+
50+ function overrideModuleMetadata ( metadata : ModuleMetadata ) {
51+ metadata . modules = metadata . imports
52+ ? metadata . imports
53+ : metadata . modules ;
54+
55+ metadata . components = metadata . providers
56+ ? metadata . providers
57+ : metadata . components ;
58+ }
0 commit comments