Skip to content

Commit

Permalink
fix(@schematics/angular): normalize differing TS AST versions in lazy…
Browse files Browse the repository at this point in the history
… module migration
  • Loading branch information
clydin authored and alexeagle committed Apr 26, 2019
1 parent 0368b89 commit 6180329
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ export class Rule extends Rules.AbstractRule {
const ruleName = this.ruleName;
const changes: RuleFailure[] = [];

ts.forEachChild(ast, function analyze(node) {
// NOTE: This should ideally be excluded at a higher level to avoid parsing
if (ast.isDeclarationFile || /[\\\/]node_modules[\\\/]/.test(ast.fileName)) {
return [];
}

// Workaround mismatched tslint TS version and vendored TS version
// The TS SyntaxKind enum numeric values change between versions
const sourceFile = ts.createSourceFile(ast.fileName, ast.text, ast.languageVersion, true);

ts.forEachChild(sourceFile, function analyze(node) {
if (ts.isPropertyAssignment(node) &&
(ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) &&
node.name.text === 'loadChildren' &&
Expand Down

0 comments on commit 6180329

Please sign in to comment.