diff --git a/package.json b/package.json index d0e341d5c46..b4cb956215a 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "precommit": "lint-staged", "test": "nyc --require ts-node/register mocha packages/**/*.spec.ts --reporter spec", "integration-test": "mocha integration/**/*.spec.ts --reporter spec --require ts-node/register", - "lint": "tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\"", + "lint": "tslint -p tsconfig.json -c tslint.json \"packages/**/*.ts\" -e \"*.spec.ts\"", "format": "prettier **/**/*.ts --ignore-path ./.prettierignore --write && git status", "build": "gulp build && gulp move", "build:lib": "gulp build --dist bundle", @@ -146,7 +146,6 @@ }, "lint-staged": { "packages/**/*.{ts,json}": [ - "npm run lint", "npm run format", "git add" ] diff --git a/packages/common/decorators/modules/module.decorator.ts b/packages/common/decorators/modules/module.decorator.ts index 7ae23082ad1..9ee56314dbe 100644 --- a/packages/common/decorators/modules/module.decorator.ts +++ b/packages/common/decorators/modules/module.decorator.ts @@ -5,6 +5,7 @@ import { ModuleMetadata } from '../../interfaces/modules/module-metadata.interfa import { InvalidModuleConfigException } from './exceptions/invalid-module-config.exception'; const metadataKeys = [ + metadata.MODULES, metadata.IMPORTS, metadata.EXPORTS, metadata.COMPONENTS, @@ -49,13 +50,21 @@ export function Module(obj: ModuleMetadata): ClassDecorator { } function overrideModuleMetadata(moduleMetadata: ModuleMetadata) { + moduleMetadata.modules = moduleMetadata.imports + ? moduleMetadata.imports + : moduleMetadata.modules; + moduleMetadata.components = moduleMetadata.providers ? moduleMetadata.providers : moduleMetadata.components; } function showDeprecatedWarnings(moduleMetadata: ModuleMetadata) { + const modulesDeprecatedWarning = + 'The "modules" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "imports" key instead.'; const componentsDeprecatetWarning = 'The "components" key in the @Module() decorator is deprecated and will be removed within next major release. Use the "providers" key instead.'; + + moduleMetadata.modules && deprecate(modulesDeprecatedWarning); moduleMetadata.components && deprecate(componentsDeprecatetWarning); } diff --git a/packages/common/interfaces/modules/module-metadata.interface.ts b/packages/common/interfaces/modules/module-metadata.interface.ts index 9bdea22bf9c..d4162e0530c 100644 --- a/packages/common/interfaces/modules/module-metadata.interface.ts +++ b/packages/common/interfaces/modules/module-metadata.interface.ts @@ -9,5 +9,8 @@ export interface ModuleMetadata { controllers?: Type[]; providers?: Provider[]; exports?: Array; + /** @deprecated */ + modules?: Array | DynamicModule | any[]>; + /** @deprecated */ components?: Provider[]; } diff --git a/packages/core/test/injector/container.spec.ts b/packages/core/test/injector/container.spec.ts index ce4e19263bd..91097459528 100644 --- a/packages/core/test/injector/container.spec.ts +++ b/packages/core/test/injector/container.spec.ts @@ -125,7 +125,7 @@ describe('NestContainer', () => { describe('extractMetadata', () => { describe('when module is a dynamic module', () => { it('should return object with "type" and "dynamicMetadata" property', () => { - const obj = { module: 'test', components: [] }; + const obj = { module: 'test', providers: [] }; const { module, ...dynamicMetadata } = obj; expect(container.extractMetadata(obj as any)).to.be.deep.equal({ type: module, diff --git a/packages/core/test/injector/injector.spec.ts b/packages/core/test/injector/injector.spec.ts index eb1c58a6ed9..05759d0ce23 100644 --- a/packages/core/test/injector/injector.spec.ts +++ b/packages/core/test/injector/injector.spec.ts @@ -511,7 +511,7 @@ describe('Injector', () => { let module; beforeEach(() => { module = { - components: [], + providers: [], }; }); diff --git a/packages/core/test/scanner.spec.ts b/packages/core/test/scanner.spec.ts index a3ff877e692..4ad868745d7 100644 --- a/packages/core/test/scanner.spec.ts +++ b/packages/core/test/scanner.spec.ts @@ -21,15 +21,15 @@ describe('DependenciesScanner', () => { class TestRoute {} @Module({ - components: [TestComponent], + providers: [TestComponent], controllers: [TestRoute], exports: [TestComponent], }) class AnotherTestModule {} @Module({ - modules: [AnotherTestModule], - components: [TestComponent], + imports: [AnotherTestModule], + providers: [TestComponent], controllers: [TestRoute], }) class TestModule {} diff --git a/tsconfig.json b/tsconfig.json index 82d6fb1a5db..77fc094f255 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,6 @@ }, "include": [ "packages/**/*", - "sample/**/*", "integration/**/*" ], "exclude": [ diff --git a/tslint.json b/tslint.json index a5e479da0da..0b575129e3f 100644 --- a/tslint.json +++ b/tslint.json @@ -17,6 +17,7 @@ "ordered-imports": [ false ], + "no-implicit-dependencies": false, "no-unnecessary-initializer": false, "unified-signatures": false, "max-line-length": [