We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3abd87a commit c402903Copy full SHA for c402903
packages/schematics/angular/utility/ast-utils.ts
@@ -189,8 +189,12 @@ export function insertAfterLastOccurrence(nodes: ts.Node[],
189
file: string,
190
fallbackPos: number,
191
syntaxKind?: ts.SyntaxKind): Change {
192
- // sort() has a side effect, so make a copy so that we won't overwrite the parent's object.
193
- let lastItem = [...nodes].sort(nodesByPosition).pop();
+ let lastItem: ts.Node | undefined;
+ for (const node of nodes) {
194
+ if (!lastItem || lastItem.getStart() < node.getStart()) {
195
+ lastItem = node;
196
+ }
197
198
if (syntaxKind && lastItem) {
199
lastItem = findNodes(lastItem, syntaxKind).sort(nodesByPosition).pop();
200
}
0 commit comments