From d66c29c96a2b118714589f50de6296b6c52ba78a Mon Sep 17 00:00:00 2001 From: "Remo H. Jansen" Date: Tue, 30 May 2017 08:43:53 +0100 Subject: [PATCH] Fixes issue #559 * Fixed #559 * Fixed coverage reports * Test in more modern versions of Node.js * Rollback chai upgrade --- .travis.yml | 6 ++--- appveyor.yml | 6 ++--- package.json | 4 +-- src/planning/reflection_utils.ts | 3 ++- test/bugs/bugs.test.ts | 42 ++++++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 82e1b05f0..9437f4998 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,9 @@ language: node_js node_js: - stable -- 5.4.1 +- 7.7.1 +- 6.9.5 - 5.4.0 -- 5.3.0 -- 5.2.0 -- 5.1.1 - 4.4.6 before_install: - npm install -g codeclimate-test-reporter diff --git a/appveyor.yml b/appveyor.yml index 43ae773bc..d2588e119 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,11 +10,9 @@ environment: matrix: - nodejs_version: "stable" - - nodejs_version: "5.4.1" + - nodejs_version: "7.7.1" + - nodejs_version: "6.9.5" - nodejs_version: "5.4.0" - - nodejs_version: "5.3.0" - - nodejs_version: "5.2.0" - - nodejs_version: "5.1.1" - nodejs_version: "4.4.6" build: off diff --git a/package.json b/package.json index 60f980710..274fe0f5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "inversify", - "version": "4.1.0", + "version": "4.1.1", "description": "A powerful and lightweight inversion of control container for JavaScript and Node.js apps powered by TypeScript.", "main": "lib/inversify.js", "jsnext:main": "es/inversify.js", @@ -46,7 +46,7 @@ "es6-symbol": "^3.1.0", "gulp": "^3.9.0", "gulp-istanbul": "^1.0.0", - "gulp-mocha": "4.3.1", + "gulp-mocha": "3.0.1", "gulp-rename": "^1.2.2", "gulp-sourcemaps": "^2.2.1", "gulp-tslint": "^8.0.0", diff --git a/src/planning/reflection_utils.ts b/src/planning/reflection_utils.ts index 3a5714fbd..1402be0b7 100644 --- a/src/planning/reflection_utils.ts +++ b/src/planning/reflection_utils.ts @@ -186,7 +186,8 @@ function getBaseClassDepencencyCount(metadataReader: interfaces.MetadataReader, if (baseConstructor !== Object) { // get targets for base class - let baseConstructorName = getFunctionName(func); + let baseConstructorName = getFunctionName(baseConstructor); + let targets = getTargets(metadataReader, baseConstructorName, baseConstructor, true); // get unmanaged metadata diff --git a/test/bugs/bugs.test.ts b/test/bugs/bugs.test.ts index 20cd7c476..81e6b9e25 100644 --- a/test/bugs/bugs.test.ts +++ b/test/bugs/bugs.test.ts @@ -807,4 +807,46 @@ describe("Bugs", () => { }); + it("Should detect missing annotations in base classes", () => { + + @injectable() + class Katana implements Katana { + public hit() { + return "cut!"; + } + } + + abstract class Warrior { + private _katana: Katana; + + public constructor( + @unmanaged() katana: Katana + ) { + this._katana = katana; + } + + public fight() {return this._katana.hit(); } + } + + @injectable() + class Ninja extends Warrior { + public constructor ( + @inject("Katana") katana: Katana + ) { + super(katana); + } + } + + let container = new Container(); + container.bind("Ninja").to(Ninja); + container.bind("Katana").to(Katana); + + const tryGet = () => { + container.get("Ninja"); + }; + + expect(tryGet).to.throw("Missing required @injectable annotation in: Warrior."); + + }); + });