Skip to content

Commit

Permalink
return to initial
Browse files Browse the repository at this point in the history
  • Loading branch information
chappelo committed Sep 23, 2024
1 parent 9a7825f commit a865a2c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/cli/src/metadataGeneration/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ export function getExtensions(decorators: ts.Identifier[], metadataGenerator: Me

const [decoratorKeyArg, decoratorValueArg] = extensionDecorator.parent.arguments;

if (!ts.isStringLiteral(decoratorKeyArg)) {
if (!ts.isStringLiteral(decoratorKeyArg) && !ts.isIdentifier(decoratorKeyArg)) {
throw new Error('The first argument of @Extension must be a string');
}

const attributeKey = decoratorKeyArg.text;
const attributeKey = ts.isIdentifier(decoratorKeyArg) ? getInitializerValue(decoratorKeyArg, metadataGenerator.typeChecker) : decoratorKeyArg.text;

if (typeof attributeKey !== 'string') {
throw new Error('The first argument of @Extension must be a string');
}

if (!decoratorValueArg) {
throw new Error(`Extension '${attributeKey}' must contain a value`);
Expand Down

0 comments on commit a865a2c

Please sign in to comment.