@@ -22,14 +22,6 @@ export function testScrubFile(content: string) {
22
22
return markers . some ( ( marker ) => content . indexOf ( marker ) !== - 1 ) ;
23
23
}
24
24
25
- // Don't remove `ctorParameters` from these.
26
- const platformWhitelist = [
27
- 'PlatformRef_' ,
28
- 'TestabilityRegistry' ,
29
- 'Console' ,
30
- 'BrowserPlatformLocation' ,
31
- ] ;
32
-
33
25
const angularSpecifiers = [
34
26
// Class level decorators.
35
27
'Component' ,
@@ -89,8 +81,7 @@ function scrubFileTransformer(checker: ts.TypeChecker, isAngularCoreFile: boolea
89
81
if ( isPropDecoratorAssignmentExpression ( exprStmt ) ) {
90
82
nodes . push ( ...pickPropDecorationNodesToRemove ( exprStmt , ngMetadata , checker ) ) ;
91
83
}
92
- if ( isCtorParamsAssignmentExpression ( exprStmt )
93
- && ! isCtorParamsWhitelistedService ( exprStmt ) ) {
84
+ if ( isCtorParamsAssignmentExpression ( exprStmt ) ) {
94
85
nodes . push ( node ) ;
95
86
}
96
87
}
@@ -369,14 +360,6 @@ function isCtorParamsAssignmentExpression(exprStmt: ts.ExpressionStatement): boo
369
360
return true ;
370
361
}
371
362
372
- function isCtorParamsWhitelistedService ( exprStmt : ts . ExpressionStatement ) : boolean {
373
- const expr = exprStmt . expression as ts . BinaryExpression ;
374
- const propAccess = expr . left as ts . PropertyAccessExpression ;
375
- const serviceId = propAccess . expression as ts . Identifier ;
376
-
377
- return platformWhitelist . indexOf ( serviceId . text ) !== - 1 ;
378
- }
379
-
380
363
// Remove Angular decorators from`Clazz.decorators = [...];`, or expression itself if all are
381
364
// removed.
382
365
function pickDecorationNodesToRemove (
@@ -435,42 +418,40 @@ function pickDecorateNodesToRemove(
435
418
return identifierIsMetadata ( id , ngMetadata , checker ) ;
436
419
} ) ;
437
420
438
- // Only remove constructor parameter metadata on non-whitelisted classes.
439
- if ( platformWhitelist . indexOf ( classId . text ) === - 1 ) {
440
- // Remove __metadata calls of type 'design:paramtypes'.
441
- const metadataCalls = elements . filter ( ( el ) => {
442
- if ( ! isTslibHelper ( el , '__metadata' , tslibImports , checker ) ) {
443
- return false ;
444
- }
445
- if ( el . arguments . length < 2 ) {
446
- return false ;
447
- }
448
- if ( el . arguments [ 0 ] . kind !== ts . SyntaxKind . StringLiteral ) {
449
- return false ;
450
- }
451
- const metadataTypeId = el . arguments [ 0 ] as ts . StringLiteral ;
452
- if ( metadataTypeId . text !== 'design:paramtypes' ) {
453
- return false ;
454
- }
455
421
456
- return true ;
457
- } ) ;
458
- // Remove all __param calls.
459
- const paramCalls = elements . filter ( ( el ) => {
460
- if ( ! isTslibHelper ( el , '__param' , tslibImports , checker ) ) {
461
- return false ;
462
- }
463
- if ( el . arguments . length != 2 ) {
464
- return false ;
465
- }
466
- if ( el . arguments [ 0 ] . kind !== ts . SyntaxKind . NumericLiteral ) {
467
- return false ;
468
- }
422
+ // Remove __metadata calls of type 'design:paramtypes'.
423
+ const metadataCalls = elements . filter ( ( el ) => {
424
+ if ( ! isTslibHelper ( el , '__metadata' , tslibImports , checker ) ) {
425
+ return false ;
426
+ }
427
+ if ( el . arguments . length < 2 ) {
428
+ return false ;
429
+ }
430
+ if ( el . arguments [ 0 ] . kind !== ts . SyntaxKind . StringLiteral ) {
431
+ return false ;
432
+ }
433
+ const metadataTypeId = el . arguments [ 0 ] as ts . StringLiteral ;
434
+ if ( metadataTypeId . text !== 'design:paramtypes' ) {
435
+ return false ;
436
+ }
469
437
470
- return true ;
471
- } ) ;
472
- ngDecoratorCalls . push ( ...metadataCalls , ...paramCalls ) ;
473
- }
438
+ return true ;
439
+ } ) ;
440
+ // Remove all __param calls.
441
+ const paramCalls = elements . filter ( ( el ) => {
442
+ if ( ! isTslibHelper ( el , '__param' , tslibImports , checker ) ) {
443
+ return false ;
444
+ }
445
+ if ( el . arguments . length != 2 ) {
446
+ return false ;
447
+ }
448
+ if ( el . arguments [ 0 ] . kind !== ts . SyntaxKind . NumericLiteral ) {
449
+ return false ;
450
+ }
451
+
452
+ return true ;
453
+ } ) ;
454
+ ngDecoratorCalls . push ( ...metadataCalls , ...paramCalls ) ;
474
455
475
456
// If all decorators are metadata decorators then return the whole `Class = __decorate([...])'`
476
457
// statement so that it is removed in entirety
0 commit comments