Skip to content

Commit 2acded4

Browse files
clydinalexeagle
authored andcommitted
fix(@schematics/angular): normalize differing TS AST versions in lazy module migration
1 parent 5f24820 commit 2acded4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/schematics/angular/migrations/update-8/rules/noLazyModulePathsRule.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,16 @@ export class Rule extends Rules.AbstractRule {
2121
const ruleName = this.ruleName;
2222
const changes: RuleFailure[] = [];
2323

24-
ts.forEachChild(ast, function analyze(node) {
24+
// NOTE: This should ideally be excluded at a higher level to avoid parsing
25+
if (ast.isDeclarationFile || /[\\\/]node_modules[\\\/]/.test(ast.fileName)) {
26+
return [];
27+
}
28+
29+
// Workaround mismatched tslint TS version and vendored TS version
30+
// The TS SyntaxKind enum numeric values change between versions
31+
const sourceFile = ts.createSourceFile(ast.fileName, ast.text, ast.languageVersion, true);
32+
33+
ts.forEachChild(sourceFile, function analyze(node) {
2534
if (ts.isPropertyAssignment(node) &&
2635
(ts.isIdentifier(node.name) || ts.isStringLiteral(node.name)) &&
2736
node.name.text === 'loadChildren' &&

0 commit comments

Comments
 (0)