Handle multiple return statements that implement interface

This commit is contained in:
Richard Knoll 2016-09-06 17:14:21 -07:00
parent 66f30c9841
commit 9c562f867d
2 changed files with 14 additions and 3 deletions

View File

@ -6417,11 +6417,15 @@ namespace ts {
return [getReferenceEntryFromNode(parent.initializer)];
}
else if (isFunctionLike(parent) && parent.type === containingTypeReference && parent.body && parent.body.kind === SyntaxKind.Block) {
return [forEachReturnStatement(<Block>parent.body, (returnStatement) => {
let result: ReferenceEntry[];
forEachReturnStatement(<Block>parent.body, (returnStatement) => {
if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) {
return getReferenceEntryFromNode(returnStatement.expression);
(result || (result = [])).push(getReferenceEntryFromNode(returnStatement.expression));
}
})];
});
return result;
}
else if (isTypeAssertionExpression(parent) && isImplementationExpression(parent.expression)) {
return [getReferenceEntryFromNode(parent.expression)];

View File

@ -4,7 +4,14 @@
//// interface Fo/*interface_definition*/o { hello: () => void }
////
//// let x: number = 9;
////
//// function createFoo(): Foo {
//// if (x === 2) {
//// return [|{
//// hello() {}
//// }|];
//// }
//// return [|{
//// hello() {}
//// }|];