Skip to content

Commit

Permalink
fix(@schematics/angular): allow insertion when there are no occurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkgs authored and kyliau committed May 9, 2019
1 parent 548fefd commit 52e9819
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/schematics/angular/utility/ast-utils.ts
Expand Up @@ -191,10 +191,7 @@ export function insertAfterLastOccurrence(nodes: ts.Node[],
syntaxKind?: ts.SyntaxKind): Change {
// sort() has a side effect, so make a copy so that we won't overwrite the parent's object.
let lastItem = [...nodes].sort(nodesByPosition).pop();
if (!lastItem) {
throw new Error();
}
if (syntaxKind) {
if (syntaxKind && lastItem) {
lastItem = findNodes(lastItem, syntaxKind).sort(nodesByPosition).pop();
}
if (!lastItem && fallbackPos == undefined) {
Expand Down

0 comments on commit 52e9819

Please sign in to comment.