@@ -83,6 +83,7 @@ namespace ts {
8383 */
8484 function transformSourceFile ( node : SourceFile ) {
8585 currentSourceFile = node ;
86+ currentScope = node ;
8687 const visited = visitEachChild ( node , visitor , context ) ;
8788 setNodeEmitFlags ( visited , NodeEmitFlags . EmitEmitHelpers | getNodeEmitFlags ( node ) ) ;
8889 return visited ;
@@ -1355,14 +1356,18 @@ namespace ts {
13551356 */
13561357 function addTypeMetadata ( node : Declaration , decoratorExpressions : Expression [ ] ) {
13571358 if ( compilerOptions . emitDecoratorMetadata ) {
1359+ let properties : ObjectLiteralElement [ ] ;
13581360 if ( shouldAddTypeMetadata ( node ) ) {
1359- decoratorExpressions . push ( createMetadataHelper ( "design: type", serializeTypeOfNode ( node ) , /*defer*/ true ) ) ;
1361+ ( properties || ( properties = [ ] ) ) . push ( createPropertyAssignment ( " type", createArrowFunction ( [ ] , serializeTypeOfNode ( node ) ) ) ) ;
13601362 }
13611363 if ( shouldAddParamTypesMetadata ( node ) ) {
1362- decoratorExpressions . push ( createMetadataHelper ( "design:paramtypes ", serializeParameterTypesOfNode ( node ) , /*defer*/ true ) ) ;
1364+ ( properties || ( properties = [ ] ) ) . push ( createPropertyAssignment ( "paramTypes ", createArrowFunction ( [ ] , serializeParameterTypesOfNode ( node ) ) ) ) ;
13631365 }
13641366 if ( shouldAddReturnTypeMetadata ( node ) ) {
1365- decoratorExpressions . push ( createMetadataHelper ( "design:returntype" , serializeReturnTypeOfNode ( node ) , /*defer*/ true ) ) ;
1367+ ( properties || ( properties = [ ] ) ) . push ( createPropertyAssignment ( "returnType" , createArrowFunction ( [ ] , serializeReturnTypeOfNode ( node ) ) ) ) ;
1368+ }
1369+ if ( properties ) {
1370+ decoratorExpressions . push ( createMetadataHelper ( "design:typeinfo" , createObjectLiteral ( properties , /*location*/ undefined , /*multiLine*/ true ) , /*defer*/ false ) ) ;
13661371 }
13671372 }
13681373 }
@@ -1483,11 +1488,11 @@ namespace ts {
14831488 * @param node The node that should have its return type serialized.
14841489 */
14851490 function serializeReturnTypeOfNode ( node : Node ) : Expression {
1486- if ( isFunctionLike ( node ) ) {
1491+ if ( isFunctionLike ( node ) && node . type ) {
14871492 return serializeTypeNode ( node . type ) ;
14881493 }
14891494
1490- return undefined ;
1495+ return createVoidZero ( ) ;
14911496 }
14921497
14931498 /**
@@ -1533,7 +1538,7 @@ namespace ts {
15331538 return createIdentifier ( "Boolean" ) ;
15341539
15351540 case SyntaxKind . StringKeyword :
1536- case SyntaxKind . StringLiteral :
1541+ case SyntaxKind . StringLiteralType :
15371542 return createIdentifier ( "String" ) ;
15381543
15391544 case SyntaxKind . NumberKeyword :
@@ -1552,6 +1557,7 @@ namespace ts {
15521557 case SyntaxKind . UnionType :
15531558 case SyntaxKind . IntersectionType :
15541559 case SyntaxKind . AnyKeyword :
1560+ case SyntaxKind . ThisType :
15551561 break ;
15561562
15571563 default :
0 commit comments