Skip to content

Commit

Permalink
Merge pull request #53 from eltociear/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
NetanelBasal authored Jun 24, 2021
2 parents e106ba6 + 08b3fcc commit 9ef2e8a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions schematics/src/utils/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,17 +190,17 @@ function nodesByPosition(first: ts.Node, second: ts.Node): number {
}

/**
* Insert `toInsert` after the last occurence of `ts.SyntaxKind[nodes[i].kind]`
* or after the last of occurence of `syntaxKind` if the last occurence is a sub child
* Insert `toInsert` after the last occurrence of `ts.SyntaxKind[nodes[i].kind]`
* or after the last of occurrence of `syntaxKind` if the last occurrence is a sub child
* of ts.SyntaxKind[nodes[i].kind] and save the changes in file.
*
* @param nodes insert after the last occurence of nodes
* @param nodes insert after the last occurrence of nodes
* @param toInsert string to insert
* @param file file to insert changes into
* @param fallbackPos position to insert if toInsert happens to be the first occurence
* @param fallbackPos position to insert if toInsert happens to be the first occurrence
* @param syntaxKind the ts.SyntaxKind of the subchildren to insert after
* @return Change instance
* @throw Error if toInsert is first occurence but fall back is not set
* @throw Error if toInsert is first occurrence but fall back is not set
*/
export function insertAfterLastOccurrence(
nodes: ts.Node[],
Expand All @@ -220,7 +220,7 @@ export function insertAfterLastOccurrence(
.pop();
}
if (!lastItem && fallbackPos == undefined) {
throw new Error(`tried to insert ${toInsert} as first occurence with no fallback position`);
throw new Error(`tried to insert ${toInsert} as first occurrence with no fallback position`);
}
const lastItemPosition: number = lastItem ? lastItem.getEnd() : fallbackPos;

Expand Down

0 comments on commit 9ef2e8a

Please sign in to comment.