@@ -3156,38 +3156,10 @@ namespace ts {
31563156 }
31573157
31583158 function getTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration) {
3159- const jsDocType = getJSDocTypeForVariableLikeDeclarationFromJSDocComment (declaration);
3160- if (jsDocType ) {
3161- return getTypeFromTypeNode(jsDocType );
3159+ const jsdocType = getJSDocType (declaration);
3160+ if (jsdocType ) {
3161+ return getTypeFromTypeNode(jsdocType );
31623162 }
3163- }
3164-
3165- function getJSDocTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration): JSDocType {
3166- // First, see if this node has an @type annotation on it directly.
3167- const typeTag = getJSDocTypeTag(declaration);
3168- if (typeTag && typeTag.typeExpression) {
3169- return typeTag.typeExpression.type;
3170- }
3171-
3172- if (declaration.kind === SyntaxKind.VariableDeclaration &&
3173- declaration.parent.kind === SyntaxKind.VariableDeclarationList &&
3174- declaration.parent.parent.kind === SyntaxKind.VariableStatement) {
3175-
3176- // @type annotation might have been on the variable statement, try that instead.
3177- const annotation = getJSDocTypeTag(declaration.parent.parent);
3178- if (annotation && annotation.typeExpression) {
3179- return annotation.typeExpression.type;
3180- }
3181- }
3182- else if (declaration.kind === SyntaxKind.Parameter) {
3183- // If it's a parameter, see if the parent has a jsdoc comment with an @param
3184- // annotation.
3185- const paramTag = getCorrespondingJSDocParameterTag(<ParameterDeclaration>declaration);
3186- if (paramTag && paramTag.typeExpression) {
3187- return paramTag.typeExpression.type;
3188- }
3189- }
3190-
31913163 return undefined;
31923164 }
31933165
@@ -3455,9 +3427,9 @@ namespace ts {
34553427 declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) {
34563428 // Use JS Doc type if present on parent expression statement
34573429 if (declaration.flags & NodeFlags.JavaScriptFile) {
3458- const typeTag = getJSDocTypeTag (declaration.parent);
3459- if (typeTag && typeTag.typeExpression ) {
3460- return links.type = getTypeFromTypeNode(typeTag.typeExpression.type );
3430+ const jsdocType = getJSDocType (declaration.parent);
3431+ if (jsdocType ) {
3432+ return links.type = getTypeFromTypeNode(jsdocType );
34613433 }
34623434 }
34633435 const declaredTypes = map(symbol.declarations,
@@ -4901,15 +4873,16 @@ namespace ts {
49014873 if (node.type && node.type.kind === SyntaxKind.JSDocOptionalType) {
49024874 return true;
49034875 }
4876+ const paramTags = getJSDocParameterTags(node);
4877+ if (paramTags) {
4878+ for (const paramTag of paramTags) {
4879+ if (paramTag.isBracketed) {
4880+ return true;
4881+ }
49044882
4905- const paramTag = getCorrespondingJSDocParameterTag(node);
4906- if (paramTag) {
4907- if (paramTag.isBracketed) {
4908- return true;
4909- }
4910-
4911- if (paramTag.typeExpression) {
4912- return paramTag.typeExpression.type.kind === SyntaxKind.JSDocOptionalType;
4883+ if (paramTag.typeExpression) {
4884+ return paramTag.typeExpression.type.kind === SyntaxKind.JSDocOptionalType;
4885+ }
49134886 }
49144887 }
49154888 }
@@ -10396,9 +10369,9 @@ namespace ts {
1039610369 }
1039710370
1039810371 function getTypeForThisExpressionFromJSDoc(node: Node) {
10399- const typeTag = getJSDocTypeTag (node);
10400- if (typeTag && typeTag.typeExpression && typeTag.typeExpression.type && typeTag.typeExpression.type .kind === SyntaxKind.JSDocFunctionType) {
10401- const jsDocFunctionType = <JSDocFunctionType>typeTag.typeExpression.type ;
10372+ const jsdocType = getJSDocType (node);
10373+ if (jsdocType && jsdocType .kind === SyntaxKind.JSDocFunctionType) {
10374+ const jsDocFunctionType = <JSDocFunctionType>jsdocType ;
1040210375 if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === SyntaxKind.JSDocThisType) {
1040310376 return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
1040410377 }
@@ -13632,7 +13605,7 @@ namespace ts {
1363213605 // the destructured type into the contained binding elements.
1363313606 function assignBindingElementTypes(node: VariableLikeDeclaration) {
1363413607 if (isBindingPattern(node.name)) {
13635- for (const element of (<BindingPattern> node.name) .elements) {
13608+ for (const element of node.name.elements) {
1363613609 if (!isOmittedExpression(element)) {
1363713610 if (element.name.kind === SyntaxKind.Identifier) {
1363813611 getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
0 commit comments