@@ -5307,10 +5307,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
5307
5307
function emitDecoratorsOfConstructor ( node : ClassLikeDeclaration ) {
5308
5308
const decorators = node . decorators ;
5309
5309
const constructor = getFirstConstructorWithBody ( node ) ;
5310
- const hasDecoratedParameters = constructor && forEach ( constructor . parameters , nodeIsDecorated ) ;
5310
+ const firstParameterDecorator = constructor && forEach ( constructor . parameters , parameter => parameter . decorators ) ;
5311
5311
5312
5312
// skip decoration of the constructor if neither it nor its parameters are decorated
5313
- if ( ! decorators && ! hasDecoratedParameters ) {
5313
+ if ( ! decorators && ! firstParameterDecorator ) {
5314
5314
return ;
5315
5315
}
5316
5316
@@ -5326,28 +5326,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
5326
5326
//
5327
5327
5328
5328
writeLine ( ) ;
5329
- emitStart ( node ) ;
5329
+ emitStart ( node . decorators || firstParameterDecorator ) ;
5330
5330
emitDeclarationName ( node ) ;
5331
5331
write ( " = __decorate([" ) ;
5332
5332
increaseIndent ( ) ;
5333
5333
writeLine ( ) ;
5334
5334
5335
5335
const decoratorCount = decorators ? decorators . length : 0 ;
5336
- let argumentsWritten = emitList ( decorators , 0 , decoratorCount , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ false , /*noTrailingNewLine*/ true , decorator => {
5337
- emitStart ( decorator ) ;
5338
- emit ( decorator . expression ) ;
5339
- emitEnd ( decorator ) ;
5340
- } ) ;
5341
-
5342
- argumentsWritten += emitDecoratorsOfParameters ( constructor , /*leadingComma*/ argumentsWritten > 0 ) ;
5336
+ let argumentsWritten = emitList ( decorators , 0 , decoratorCount , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ false , /*noTrailingNewLine*/ true ,
5337
+ decorator => emit ( decorator . expression ) ) ;
5338
+ if ( firstParameterDecorator ) {
5339
+ argumentsWritten += emitDecoratorsOfParameters ( constructor , /*leadingComma*/ argumentsWritten > 0 ) ;
5340
+ }
5343
5341
emitSerializedTypeMetadata ( node , /*leadingComma*/ argumentsWritten >= 0 ) ;
5344
5342
5345
5343
decreaseIndent ( ) ;
5346
5344
writeLine ( ) ;
5347
5345
write ( "], " ) ;
5348
5346
emitDeclarationName ( node ) ;
5349
- write ( ");" ) ;
5350
- emitEnd ( node ) ;
5347
+ write ( ")" ) ;
5348
+ emitEnd ( node . decorators || firstParameterDecorator ) ;
5349
+ write ( ";" ) ;
5351
5350
writeLine ( ) ;
5352
5351
}
5353
5352
@@ -5363,11 +5362,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
5363
5362
continue ;
5364
5363
}
5365
5364
5366
- // skip a member if it or any of its parameters are not decorated
5367
- if ( ! nodeOrChildIsDecorated ( member ) ) {
5368
- continue ;
5369
- }
5370
-
5371
5365
// skip an accessor declaration if it is not the first accessor
5372
5366
let decorators : NodeArray < Decorator > ;
5373
5367
let functionLikeMember : FunctionLikeDeclaration ;
@@ -5394,6 +5388,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
5394
5388
functionLikeMember = < MethodDeclaration > member ;
5395
5389
}
5396
5390
}
5391
+ const firstParameterDecorator = functionLikeMember && forEach ( functionLikeMember . parameters , parameter => parameter . decorators ) ;
5392
+
5393
+ // skip a member if it or any of its parameters are not decorated
5394
+ if ( ! decorators && ! firstParameterDecorator ) {
5395
+ continue ;
5396
+ }
5397
5397
5398
5398
// Emit the call to __decorate. Given the following:
5399
5399
//
@@ -5427,29 +5427,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
5427
5427
//
5428
5428
5429
5429
writeLine ( ) ;
5430
- emitStart ( member ) ;
5430
+ emitStart ( decorators || firstParameterDecorator ) ;
5431
5431
write ( "__decorate([" ) ;
5432
5432
increaseIndent ( ) ;
5433
5433
writeLine ( ) ;
5434
5434
5435
5435
const decoratorCount = decorators ? decorators . length : 0 ;
5436
- let argumentsWritten = emitList ( decorators , 0 , decoratorCount , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ false , /*noTrailingNewLine*/ true , decorator => {
5437
- emitStart ( decorator ) ;
5438
- emit ( decorator . expression ) ;
5439
- emitEnd ( decorator ) ;
5440
- } ) ;
5436
+ let argumentsWritten = emitList ( decorators , 0 , decoratorCount , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ false , /*noTrailingNewLine*/ true ,
5437
+ decorator => emit ( decorator . expression ) ) ;
5441
5438
5442
- argumentsWritten += emitDecoratorsOfParameters ( functionLikeMember , argumentsWritten > 0 ) ;
5439
+ if ( firstParameterDecorator ) {
5440
+ argumentsWritten += emitDecoratorsOfParameters ( functionLikeMember , argumentsWritten > 0 ) ;
5441
+ }
5443
5442
emitSerializedTypeMetadata ( member , argumentsWritten > 0 ) ;
5444
5443
5445
5444
decreaseIndent ( ) ;
5446
5445
writeLine ( ) ;
5447
5446
write ( "], " ) ;
5448
- emitStart ( member . name ) ;
5449
5447
emitClassMemberPrefix ( node , member ) ;
5450
5448
write ( ", " ) ;
5451
5449
emitExpressionForPropertyName ( member . name ) ;
5452
- emitEnd ( member . name ) ;
5453
5450
5454
5451
if ( languageVersion > ScriptTarget . ES3 ) {
5455
5452
if ( member . kind !== SyntaxKind . PropertyDeclaration ) {
@@ -5464,8 +5461,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
5464
5461
}
5465
5462
}
5466
5463
5467
- write ( ");" ) ;
5468
- emitEnd ( member ) ;
5464
+ write ( ")" ) ;
5465
+ emitEnd ( decorators || firstParameterDecorator ) ;
5466
+ write ( ";" ) ;
5469
5467
writeLine ( ) ;
5470
5468
}
5471
5469
}
@@ -5478,11 +5476,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
5478
5476
if ( nodeIsDecorated ( parameter ) ) {
5479
5477
const decorators = parameter . decorators ;
5480
5478
argumentsWritten += emitList ( decorators , 0 , decorators . length , /*multiLine*/ true , /*trailingComma*/ false , /*leadingComma*/ leadingComma , /*noTrailingNewLine*/ true , decorator => {
5481
- emitStart ( decorator ) ;
5482
5479
write ( `__param(${ parameterIndex } , ` ) ;
5483
5480
emit ( decorator . expression ) ;
5484
5481
write ( ")" ) ;
5485
- emitEnd ( decorator ) ;
5486
5482
} ) ;
5487
5483
leadingComma = true ;
5488
5484
}
0 commit comments