mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-16 15:45:27 -05:00
fix(35050): Decorator emit incorrect within try block (#41951)
* fix(35050): fix decorated block-scoped class emit * Only use internal name when targeting ES5/3 Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
This commit is contained in:
@@ -823,7 +823,12 @@ namespace ts {
|
||||
|
||||
const location = moveRangePastDecorators(node);
|
||||
const classAlias = getClassAliasIfNeeded(node);
|
||||
const declName = factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
||||
|
||||
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
|
||||
// without any block-scoped variable collision handling
|
||||
const declName = languageVersion <= ScriptTarget.ES2015 ?
|
||||
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
|
||||
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
||||
|
||||
// ... = class ${name} ${heritageClauses} {
|
||||
// ${members}
|
||||
@@ -1233,7 +1238,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
const classAlias = classAliases && classAliases[getOriginalNodeId(node)];
|
||||
const localName = factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
||||
|
||||
// When we transform to ES5/3 this will be moved inside an IIFE and should reference the name
|
||||
// without any block-scoped variable collision handling
|
||||
const localName = languageVersion <= ScriptTarget.ES2015 ?
|
||||
factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) :
|
||||
factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true);
|
||||
const decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
|
||||
const expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
|
||||
setEmitFlags(expression, EmitFlags.NoComments);
|
||||
|
||||
Reference in New Issue
Block a user