Serialize return types as proper AST tokens

This commit is contained in:
joeduffy 2017-01-21 12:14:25 -08:00
parent bbdc18652c
commit 6209b65a36
2 changed files with 13 additions and 4 deletions

View file

@ -121,7 +121,7 @@ interface FunctionLikeDeclaration {
name: ast.Identifier;
parameters: ast.LocalVariable[];
body?: ast.Block;
returnType?: symbols.TypeToken;
returnType?: ast.TypeToken;
}
// TypeLike is any interface that has a possible TypeNode attached to it and can be queried for binding information.
@ -1035,10 +1035,16 @@ export class Transformer {
}
// Get the signature so that we can fetch the return type.
let returnType: symbols.TypeToken | undefined;
let returnType: ast.TypeToken | undefined;
if (node.kind !== ts.SyntaxKind.Constructor) {
let signature: ts.Signature = this.checker().getSignatureFromDeclaration(node);
returnType = this.resolveTypeToken(signature.getReturnType());
let typeToken: symbols.TypeToken | undefined = this.resolveTypeToken(signature.getReturnType());
if (typeToken) {
returnType = <ast.TypeToken>{
kind: ast.typeTokenKind,
tok: typeToken,
};
}
}
// Delegate to the factory method to turn this into a real function object.

View file

@ -697,7 +697,10 @@
}
}
},
"returnType": "Point",
"returnType": {
"kind": "TypeToken",
"tok": "Point"
},
"static": false,
"abstract": false,
"loc": {