From a865a2c79d47ad1f198811f850e5e6ffe176fd74 Mon Sep 17 00:00:00 2001 From: Josh Chappelow Date: Sun, 15 Sep 2024 22:58:32 +0900 Subject: [PATCH] return to initial --- packages/cli/src/metadataGeneration/extension.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/metadataGeneration/extension.ts b/packages/cli/src/metadataGeneration/extension.ts index 08ee2ffc4..69c43be27 100644 --- a/packages/cli/src/metadataGeneration/extension.ts +++ b/packages/cli/src/metadataGeneration/extension.ts @@ -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`);