@@ -22,14 +22,6 @@ export function testScrubFile(content: string) {
2222 return markers . some ( ( marker ) => content . indexOf ( marker ) !== - 1 ) ;
2323}
2424
25- // Don't remove `ctorParameters` from these.
26- const platformWhitelist = [
27- 'PlatformRef_' ,
28- 'TestabilityRegistry' ,
29- 'Console' ,
30- 'BrowserPlatformLocation' ,
31- ] ;
32-
3325const angularSpecifiers = [
3426 // Class level decorators.
3527 'Component' ,
@@ -89,8 +81,7 @@ function scrubFileTransformer(checker: ts.TypeChecker, isAngularCoreFile: boolea
8981 if ( isPropDecoratorAssignmentExpression ( exprStmt ) ) {
9082 nodes . push ( ...pickPropDecorationNodesToRemove ( exprStmt , ngMetadata , checker ) ) ;
9183 }
92- if ( isCtorParamsAssignmentExpression ( exprStmt )
93- && ! isCtorParamsWhitelistedService ( exprStmt ) ) {
84+ if ( isCtorParamsAssignmentExpression ( exprStmt ) ) {
9485 nodes . push ( node ) ;
9586 }
9687 }
@@ -369,14 +360,6 @@ function isCtorParamsAssignmentExpression(exprStmt: ts.ExpressionStatement): boo
369360 return true ;
370361}
371362
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-
380363// Remove Angular decorators from`Clazz.decorators = [...];`, or expression itself if all are
381364// removed.
382365function pickDecorationNodesToRemove (
@@ -435,42 +418,40 @@ function pickDecorateNodesToRemove(
435418 return identifierIsMetadata ( id , ngMetadata , checker ) ;
436419 } ) ;
437420
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- }
455421
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+ }
469437
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 ) ;
474455
475456 // If all decorators are metadata decorators then return the whole `Class = __decorate([...])'`
476457 // statement so that it is removed in entirety
0 commit comments