fix(ngcc): better detection of end of decorator expression (#33192)
for removal of decorator from __decorate calls. FW-1629 #resolve PR Close #33192
This commit is contained in:

committed by
Matias Niemelä

parent
4da2dda647
commit
50710838bf
@ -99,9 +99,17 @@ export class EsmRenderingFormatter implements RenderingFormatter {
|
||||
} else {
|
||||
nodesToRemove.forEach(node => {
|
||||
// remove any trailing comma
|
||||
const end = (output.slice(node.getEnd(), node.getEnd() + 1) === ',') ?
|
||||
node.getEnd() + 1 :
|
||||
node.getEnd();
|
||||
const nextSibling = getNextSiblingInArray(node, items);
|
||||
let end: number;
|
||||
|
||||
if (nextSibling !== null &&
|
||||
output.slice(nextSibling.getFullStart() - 1, nextSibling.getFullStart()) === ',') {
|
||||
end = nextSibling.getFullStart() - 1 + nextSibling.getLeadingTriviaWidth();
|
||||
} else if (output.slice(node.getEnd(), node.getEnd() + 1) === ',') {
|
||||
end = node.getEnd() + 1;
|
||||
} else {
|
||||
end = node.getEnd();
|
||||
}
|
||||
output.remove(node.getFullStart(), end);
|
||||
});
|
||||
}
|
||||
@ -214,3 +222,8 @@ function generateImportString(
|
||||
const importAs = importPath ? importManager.generateNamedImport(importPath, importName) : null;
|
||||
return importAs ? `${importAs.moduleImport}.${importAs.symbol}` : `${importName}`;
|
||||
}
|
||||
|
||||
function getNextSiblingInArray<T extends ts.Node>(node: T, array: ts.NodeArray<T>): T|null {
|
||||
const index = array.indexOf(node);
|
||||
return index !== -1 && array.length > index + 1 ? array[index + 1] : null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user