@@ -5007,14 +5007,27 @@ namespace ts {
50075007 }
50085008
50095009 /**
5010- * Gets the return type node for the node if provided via JSDoc's return tag.
5010+ * Gets the return type node for the node if provided via JSDoc return tag or type tag.
50115011 *
50125012 * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function
5013- * gets the type from inside the braces.
5013+ * gets the type from inside the braces, after the fat arrow, etc .
50145014 */
50155015 export function getJSDocReturnType ( node : Node ) : TypeNode | undefined {
50165016 const returnTag = getJSDocReturnTag ( node ) ;
5017- return returnTag && returnTag . typeExpression && returnTag . typeExpression . type ;
5017+ if ( returnTag && returnTag . typeExpression ) {
5018+ return returnTag . typeExpression . type ;
5019+ }
5020+ const typeTag = getJSDocTypeTag ( node ) ;
5021+ if ( typeTag && typeTag . typeExpression ) {
5022+ const type = typeTag . typeExpression . type ;
5023+ if ( isTypeLiteralNode ( type ) ) {
5024+ const sig = find ( type . members , isCallSignatureDeclaration ) ;
5025+ return sig && sig . type ;
5026+ }
5027+ if ( isFunctionTypeNode ( type ) ) {
5028+ return type . type ;
5029+ }
5030+ }
50185031 }
50195032
50205033 /** Get all JSDoc tags related to a node, including those on parent nodes. */
@@ -6572,45 +6585,6 @@ namespace ts {
65726585 return ! ! ( node as HasType ) . type ;
65736586 }
65746587
6575- /* True if the node could have a type node a `.type` */
6576- /* @internal */
6577- export function couldHaveType ( node : Node ) : node is HasType {
6578- switch ( node . kind ) {
6579- case SyntaxKind . Parameter :
6580- case SyntaxKind . PropertySignature :
6581- case SyntaxKind . PropertyDeclaration :
6582- case SyntaxKind . MethodSignature :
6583- case SyntaxKind . MethodDeclaration :
6584- case SyntaxKind . Constructor :
6585- case SyntaxKind . GetAccessor :
6586- case SyntaxKind . SetAccessor :
6587- case SyntaxKind . CallSignature :
6588- case SyntaxKind . ConstructSignature :
6589- case SyntaxKind . IndexSignature :
6590- case SyntaxKind . TypePredicate :
6591- case SyntaxKind . FunctionType :
6592- case SyntaxKind . ConstructorType :
6593- case SyntaxKind . ParenthesizedType :
6594- case SyntaxKind . TypeOperator :
6595- case SyntaxKind . MappedType :
6596- case SyntaxKind . TypeAssertionExpression :
6597- case SyntaxKind . FunctionExpression :
6598- case SyntaxKind . ArrowFunction :
6599- case SyntaxKind . AsExpression :
6600- case SyntaxKind . VariableDeclaration :
6601- case SyntaxKind . FunctionDeclaration :
6602- case SyntaxKind . TypeAliasDeclaration :
6603- case SyntaxKind . JSDocTypeExpression :
6604- case SyntaxKind . JSDocNullableType :
6605- case SyntaxKind . JSDocNonNullableType :
6606- case SyntaxKind . JSDocOptionalType :
6607- case SyntaxKind . JSDocFunctionType :
6608- case SyntaxKind . JSDocVariadicType :
6609- return true ;
6610- }
6611- return false ;
6612- }
6613-
66146588 /** True if has initializer node attached to it. */
66156589 /* @internal */
66166590 export function hasInitializer ( node : Node ) : node is HasInitializer {
0 commit comments