diff --git a/CHANGELOG.md b/CHANGELOG.md index fe3cfa2..6e6e7ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v0.20.4 + +* Improved error messaging with `@override` when feature is missing +* Fixed source code typos + ## v0.20.3 * Fixed bug [#202](https://github.com/final-hill/decorator-contracts/issues/202) diff --git a/package-lock.json b/package-lock.json index 9680687..202a27c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@final-hill/decorator-contracts", - "version": "0.20.3", + "version": "0.20.4", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index e31a466..910ad5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@final-hill/decorator-contracts", - "version": "0.20.3", + "version": "0.20.4", "description": "Code Contracts for TypeScript and ECMAScript classes", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/lib/Feature.ts b/src/lib/Feature.ts index cff0231..bee359f 100644 --- a/src/lib/Feature.ts +++ b/src/lib/Feature.ts @@ -9,10 +9,10 @@ import ClassRegistration from './ClassRegistration'; class Feature { #descriptor: PropertyDescriptor; - #overridenOriginalDescriptor: PropertyDescriptor | undefined; + #overriddenOriginalDescriptor: PropertyDescriptor | undefined; /** - * Does the current feature have an @override declaration? + * Does the current feature have an `@override` declaration? */ hasOverrides = false; @@ -98,16 +98,16 @@ class Feature { /** * Returns the original feature descriptor which was replaced by the `override` decorator */ - get overridenOriginalDescriptor(): PropertyDescriptor| undefined { - return this.#overridenOriginalDescriptor; + get overriddenOriginalDescriptor(): PropertyDescriptor| undefined { + return this.#overriddenOriginalDescriptor; } /** * Sets the feature descriptor. Used by the `override` decorator. * @param {PropertyDescriptor} value - The descriptor to save */ - set overridenOriginalDescriptor(value: PropertyDescriptor | undefined) { - this.#overridenOriginalDescriptor = value; + set overriddenOriginalDescriptor(value: PropertyDescriptor | undefined) { + this.#overriddenOriginalDescriptor = value; } /** diff --git a/src/override.ts b/src/override.ts index bd4688f..0e755ae 100644 --- a/src/override.ts +++ b/src/override.ts @@ -28,7 +28,7 @@ function override(target: Record, propertyKey: PropertyKey, de const registration = CLASS_REGISTRY.getOrCreate(Class), feature = registration.findFeature(propertyKey); - assert(feature != null, MSG_MISSING_FEATURE); + assert(feature != null, `${MSG_MISSING_FEATURE}: ${registration.Class.name}.prototype.${String(propertyKey)}`); const ancFeature = feature.ancestorFeature; @@ -42,7 +42,7 @@ function override(target: Record, propertyKey: PropertyKey, de assert(thisMethod.length == ancMethod.length, MSG_INVALID_ARG_LENGTH); } - feature.overridenOriginalDescriptor = descriptor; + feature.overriddenOriginalDescriptor = descriptor; // method decorators are evaluated before class decorators return {