Skip to content

Commit

Permalink
fix(nest): remove duplicate storage of method decorator values
Browse files Browse the repository at this point in the history
Now that we are pulling the method descriptor on get we don't need to save like a property
  • Loading branch information
CarsonF committed Sep 28, 2024
1 parent b2676f0 commit 06d9bd5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions packages/nest/src/metadata-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ export const createMetadataDecorator = <
return val;
}

// MethodDecorator / PropertyDecorator
if (property) {
// PropertyDecorator
let val = getMetadata(id, target, property);
if (val !== undefined) {
return val;
}
// Fall back to descriptor
// aka: get(new Class().method)

// MethodDecorator
const descriptor = Object.getOwnPropertyDescriptor(
target.prototype,
property,
Expand Down Expand Up @@ -267,10 +267,6 @@ export const createMetadataDecorator = <
type: 'method',
});
}
// Allow access via: get(Class, 'method')
defineMetadata(id, next, staticCls, property!);
// Allow access via: get(new Class().method)
// NestJS does this
defineMetadata(id, next, descriptor.value);
return descriptor;
}
Expand Down

0 comments on commit 06d9bd5

Please sign in to comment.