mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 17:27:54 -05:00
Fix getEffectiveTypeAnnotationNode
Prevent it from using the (return) type of a function. Could also check the condition before calling the function, but there are two places that need the check, and OTOH, all calls check the result so returning `undefined` should work. (This problem was introduced in PR#32553.) Fixes #33741.
This commit is contained in:
@@ -3865,9 +3865,11 @@ namespace ts {
|
||||
|
||||
/**
|
||||
* Gets the effective type annotation of a variable, parameter, or property. If the node was
|
||||
* parsed in a JavaScript file, gets the type annotation from JSDoc.
|
||||
* parsed in a JavaScript file, gets the type annotation from JSDoc. Also gets the type of
|
||||
* functions only the JSDoc case.
|
||||
*/
|
||||
export function getEffectiveTypeAnnotationNode(node: Node): TypeNode | undefined {
|
||||
if (!isInJSFile(node) && isFunctionDeclaration(node)) return undefined;
|
||||
const type = (node as HasType).type;
|
||||
if (type || !isInJSFile(node)) return type;
|
||||
return isJSDocPropertyLikeTag(node) ? node.typeExpression && node.typeExpression.type : getJSDocType(node);
|
||||
|
||||
Reference in New Issue
Block a user