Skip to content

Commit

Permalink
fix(metadata-explorer.ts): fix missing props from base class
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Feb 10, 2020
1 parent 3adaf85 commit 2e4ec7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/metadata-explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@ class MetadataManager {
model: TModel,
metadata: MetadataMapList<TModel>
) {
const existingMetadata = this._metadataMap.get(model) || [];
const existingProtoMetadata = Object.getPrototypeOf(model)
? this._metadataMap.get(Object.getPrototypeOf(model)) || []
: [];

this._metadataMap.set(model, [
...(this._metadataMap.has(model) ? this.getMetadata(model) : []),
...existingProtoMetadata,
...existingMetadata,
...metadata,
]);
}
Expand Down
9 changes: 8 additions & 1 deletion test/metadata-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { AutoMap } from '../src';
import { instantiate } from '../src/metadata-explorer';

describe('MetadataManager', () => {
class Base {
@AutoMap()
createdAt!: Date;
@AutoMap()
updatedAt!: Date;
}

class Address {
@AutoMap()
street!: string;
Expand All @@ -11,7 +18,7 @@ describe('MetadataManager', () => {
state!: string;
}

class User {
class User extends Base {
@AutoMap()
firstName!: string;
@AutoMap()
Expand Down

0 comments on commit 2e4ec7d

Please sign in to comment.