@@ -3156,38 +3156,10 @@ namespace ts {
3156
3156
}
3157
3157
3158
3158
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 );
3162
3162
}
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
-
3191
3163
return undefined;
3192
3164
}
3193
3165
@@ -3455,9 +3427,9 @@ namespace ts {
3455
3427
declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) {
3456
3428
// Use JS Doc type if present on parent expression statement
3457
3429
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 );
3461
3433
}
3462
3434
}
3463
3435
const declaredTypes = map(symbol.declarations,
@@ -4901,15 +4873,16 @@ namespace ts {
4901
4873
if (node.type && node.type.kind === SyntaxKind.JSDocOptionalType) {
4902
4874
return true;
4903
4875
}
4876
+ const paramTags = getJSDocParameterTags(node);
4877
+ if (paramTags) {
4878
+ for (const paramTag of paramTags) {
4879
+ if (paramTag.isBracketed) {
4880
+ return true;
4881
+ }
4904
4882
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
+ }
4913
4886
}
4914
4887
}
4915
4888
}
@@ -10396,9 +10369,9 @@ namespace ts {
10396
10369
}
10397
10370
10398
10371
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 ;
10402
10375
if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === SyntaxKind.JSDocThisType) {
10403
10376
return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
10404
10377
}
@@ -13632,7 +13605,7 @@ namespace ts {
13632
13605
// the destructured type into the contained binding elements.
13633
13606
function assignBindingElementTypes(node: VariableLikeDeclaration) {
13634
13607
if (isBindingPattern(node.name)) {
13635
- for (const element of (<BindingPattern> node.name) .elements) {
13608
+ for (const element of node.name.elements) {
13636
13609
if (!isOmittedExpression(element)) {
13637
13610
if (element.name.kind === SyntaxKind.Identifier) {
13638
13611
getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
0 commit comments