@@ -5292,10 +5292,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
52925292 function emitDecoratorsOfConstructor ( node : ClassLikeDeclaration ) {
52935293 const decorators = node . decorators ;
52945294 const constructor = getFirstConstructorWithBody ( node ) ;
5295- const hasDecoratedParameters = constructor && forEach ( constructor . parameters , nodeIsDecorated ) ;
5295+ const firstParameterDecorator = constructor && forEach ( constructor . parameters , parameter => parameter . decorators ) ;
52965296
52975297 // skip decoration of the constructor if neither it nor its parameters are decorated
5298- if ( ! decorators && ! hasDecoratedParameters ) {
5298+ if ( ! decorators && ! firstParameterDecorator ) {
52995299 return ;
53005300 }
53015301
@@ -5311,28 +5311,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
53115311 //
53125312
53135313 writeLine ( ) ;
5314- emitStart ( node ) ;
5314+ emitStart ( node . decorators || firstParameterDecorator ) ;
53155315 emitDeclarationName ( node ) ;
53165316 write ( " = __decorate([" ) ;
53175317 increaseIndent ( ) ;
53185318 writeLine ( ) ;
53195319
53205320 const decoratorCount = decorators ? decorators . length : 0 ;
5321- let argumentsWritten = emitList ( decorators , 0 , decoratorCount , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ false , /*noTrailingNewLine*/ true , decorator => {
5322- emitStart ( decorator ) ;
5323- emit ( decorator . expression ) ;
5324- emitEnd ( decorator ) ;
5325- } ) ;
5326-
5327- argumentsWritten += emitDecoratorsOfParameters ( constructor , /*leadingComma*/ argumentsWritten > 0 ) ;
5321+ let argumentsWritten = emitList ( decorators , 0 , decoratorCount , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ false , /*noTrailingNewLine*/ true ,
5322+ decorator => emit ( decorator . expression ) ) ;
5323+ if ( firstParameterDecorator ) {
5324+ argumentsWritten += emitDecoratorsOfParameters ( constructor , /*leadingComma*/ argumentsWritten > 0 ) ;
5325+ }
53285326 emitSerializedTypeMetadata ( node , /*leadingComma*/ argumentsWritten >= 0 ) ;
53295327
53305328 decreaseIndent ( ) ;
53315329 writeLine ( ) ;
53325330 write ( "], " ) ;
53335331 emitDeclarationName ( node ) ;
5334- write ( ");" ) ;
5335- emitEnd ( node ) ;
5332+ write ( ")" ) ;
5333+ emitEnd ( node . decorators || firstParameterDecorator ) ;
5334+ write ( ";" ) ;
53365335 writeLine ( ) ;
53375336 }
53385337
@@ -5348,11 +5347,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
53485347 continue ;
53495348 }
53505349
5351- // skip a member if it or any of its parameters are not decorated
5352- if ( ! nodeOrChildIsDecorated ( member ) ) {
5353- continue ;
5354- }
5355-
53565350 // skip an accessor declaration if it is not the first accessor
53575351 let decorators : NodeArray < Decorator > ;
53585352 let functionLikeMember : FunctionLikeDeclaration ;
@@ -5379,6 +5373,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
53795373 functionLikeMember = < MethodDeclaration > member ;
53805374 }
53815375 }
5376+ const firstParameterDecorator = functionLikeMember && forEach ( functionLikeMember . parameters , parameter => parameter . decorators ) ;
5377+
5378+ // skip a member if it or any of its parameters are not decorated
5379+ if ( ! decorators && ! firstParameterDecorator ) {
5380+ continue ;
5381+ }
53825382
53835383 // Emit the call to __decorate. Given the following:
53845384 //
@@ -5412,29 +5412,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
54125412 //
54135413
54145414 writeLine ( ) ;
5415- emitStart ( member ) ;
5415+ emitStart ( decorators || firstParameterDecorator ) ;
54165416 write ( "__decorate([" ) ;
54175417 increaseIndent ( ) ;
54185418 writeLine ( ) ;
54195419
54205420 const decoratorCount = decorators ? decorators . length : 0 ;
5421- let argumentsWritten = emitList ( decorators , 0 , decoratorCount , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ false , /*noTrailingNewLine*/ true , decorator => {
5422- emitStart ( decorator ) ;
5423- emit ( decorator . expression ) ;
5424- emitEnd ( decorator ) ;
5425- } ) ;
5421+ let argumentsWritten = emitList ( decorators , 0 , decoratorCount , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ false , /*noTrailingNewLine*/ true ,
5422+ decorator => emit ( decorator . expression ) ) ;
54265423
5427- argumentsWritten += emitDecoratorsOfParameters ( functionLikeMember , argumentsWritten > 0 ) ;
5424+ if ( firstParameterDecorator ) {
5425+ argumentsWritten += emitDecoratorsOfParameters ( functionLikeMember , argumentsWritten > 0 ) ;
5426+ }
54285427 emitSerializedTypeMetadata ( member , argumentsWritten > 0 ) ;
54295428
54305429 decreaseIndent ( ) ;
54315430 writeLine ( ) ;
54325431 write ( "], " ) ;
5433- emitStart ( member . name ) ;
54345432 emitClassMemberPrefix ( node , member ) ;
54355433 write ( ", " ) ;
54365434 emitExpressionForPropertyName ( member . name ) ;
5437- emitEnd ( member . name ) ;
54385435
54395436 if ( languageVersion > ScriptTarget . ES3 ) {
54405437 if ( member . kind !== SyntaxKind . PropertyDeclaration ) {
@@ -5449,8 +5446,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
54495446 }
54505447 }
54515448
5452- write ( ");" ) ;
5453- emitEnd ( member ) ;
5449+ write ( ")" ) ;
5450+ emitEnd ( decorators || firstParameterDecorator ) ;
5451+ write ( ";" ) ;
54545452 writeLine ( ) ;
54555453 }
54565454 }
@@ -5463,11 +5461,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
54635461 if ( nodeIsDecorated ( parameter ) ) {
54645462 const decorators = parameter . decorators ;
54655463 argumentsWritten += emitList ( decorators , 0 , decorators . length , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ leadingComma , /*noTrailingNewLine*/ true , decorator => {
5466- emitStart ( decorator ) ;
54675464 write ( `__param(${ parameterIndex } , ` ) ;
54685465 emit ( decorator . expression ) ;
54695466 write ( ")" ) ;
5470- emitEnd ( decorator ) ;
54715467 } ) ;
54725468 leadingComma = true ;
54735469 }
0 commit comments