Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 9deb7b8

Browse files
Broccoclydin
authored andcommitted
fix(@schematics/angular): Use correct TS position functions.
Fixes angular/angular-cli#8520
1 parent c0d8f2c commit 9deb7b8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/schematics/angular/utility/ast-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function findNode(node: ts.Node, kind: ts.SyntaxKind, text: string): ts.N
8989
* @return function to sort nodes in increasing order of position in sourceFile
9090
*/
9191
function nodesByPosition(first: ts.Node, second: ts.Node): number {
92-
return first.pos - second.pos;
92+
return first.getStart() - second.getStart();
9393
}
9494

9595

@@ -121,7 +121,7 @@ export function insertAfterLastOccurrence(nodes: ts.Node[],
121121
if (!lastItem && fallbackPos == undefined) {
122122
throw new Error(`tried to insert ${toInsert} as first occurence with no fallback position`);
123123
}
124-
const lastItemPosition: number = lastItem ? lastItem.end : fallbackPos;
124+
const lastItemPosition: number = lastItem ? lastItem.getEnd() : fallbackPos;
125125

126126
return new InsertChange(file, lastItemPosition, toInsert);
127127
}

0 commit comments

Comments
 (0)