@@ -47,15 +47,13 @@ function scrubFileTransformer(program: ts.Program | undefined, isAngularCoreFile
47
47
ts . forEachChild ( sf , checkNodeForDecorators ) ;
48
48
49
49
function checkNodeForDecorators ( node : ts . Node ) : void {
50
- if ( node . kind !== ts . SyntaxKind . ExpressionStatement ) {
51
- // TS 2.4 nests decorators inside downleveled class IIFEs, so we
52
- // must recurse into them to find the relevant expression statements.
50
+ if ( ! ts . isExpressionStatement ( node ) ) {
53
51
return ts . forEachChild ( node , checkNodeForDecorators ) ;
54
52
}
53
+
55
54
const exprStmt = node as ts . ExpressionStatement ;
56
55
// Do checks that don't need the typechecker first and bail early.
57
- if ( isIvyPrivateCallExpression ( exprStmt )
58
- || isCtorParamsAssignmentExpression ( exprStmt ) ) {
56
+ if ( isIvyPrivateCallExpression ( exprStmt ) || isCtorParamsAssignmentExpression ( exprStmt ) ) {
59
57
nodes . push ( node ) ;
60
58
} else if ( isDecoratorAssignmentExpression ( exprStmt ) ) {
61
59
nodes . push ( ...pickDecorationNodesToRemove ( exprStmt , ngMetadata , checker ) ) ;
@@ -360,7 +358,7 @@ function pickDecorationNodesToRemove(
360
358
const expr = expect < ts . BinaryExpression > ( exprStmt . expression , ts . SyntaxKind . BinaryExpression ) ;
361
359
const literal = expect < ts . ArrayLiteralExpression > ( expr . right ,
362
360
ts . SyntaxKind . ArrayLiteralExpression ) ;
363
- if ( ! literal . elements . every ( ( elem ) => elem . kind === ts . SyntaxKind . ObjectLiteralExpression ) ) {
361
+ if ( ! literal . elements . every ( elem => ts . isObjectLiteralExpression ( elem ) ) ) {
364
362
return [ ] ;
365
363
}
366
364
const elements = literal . elements as ts . NodeArray < ts . ObjectLiteralExpression > ;
@@ -451,8 +449,8 @@ function pickPropDecorationNodesToRemove(
451
449
const expr = expect < ts . BinaryExpression > ( exprStmt . expression , ts . SyntaxKind . BinaryExpression ) ;
452
450
const literal = expect < ts . ObjectLiteralExpression > ( expr . right ,
453
451
ts . SyntaxKind . ObjectLiteralExpression ) ;
454
- if ( ! literal . properties . every ( ( elem ) => elem . kind === ts . SyntaxKind . PropertyAssignment &&
455
- ( elem as ts . PropertyAssignment ) . initializer . kind === ts . SyntaxKind . ArrayLiteralExpression ) ) {
452
+ if ( ! literal . properties . every ( elem => ts . isPropertyAssignment ( elem )
453
+ && ts . isArrayLiteralExpression ( elem . initializer ) ) ) {
456
454
return [ ] ;
457
455
}
458
456
const assignments = literal . properties as ts . NodeArray < ts . PropertyAssignment > ;
@@ -482,8 +480,7 @@ function pickPropDecorationNodesToRemove(
482
480
// If every node to be removed is a property assignment (full property's decorators) and
483
481
// all properties are accounted for, remove the whole assignment. Otherwise, remove the
484
482
// nodes which were marked as safe.
485
- if ( toRemove . length === assignments . length &&
486
- toRemove . every ( ( node ) => node . kind === ts . SyntaxKind . PropertyAssignment ) ) {
483
+ if ( toRemove . length === assignments . length && toRemove . every ( ( node ) => ts . isPropertyAssignment ( node ) ) ) {
487
484
return [ exprStmt ] ;
488
485
}
489
486
0 commit comments