Shrink error span on @type errors for signatures (#42024)

Previously, the error span was too large on @type errors on functions
when the type was not a function. The span covered the entire tag. This
PR changes the error node just to be the type of the type tag. In other words,
the error span was previously this:

```
@type {IncorrectType}
```

But is now just this:

```
IncorrectType
```

Fixes the first error from #41974, but not the other two.

Co-authored-by: Ashya Manning <ashyamanning@pursuit.org>
Co-authored-by: Nilber Remon <nilberremon@gmail.com>

Co-authored-by: Ashya Manning <ashyamanning@pursuit.org>
Co-authored-by: Nilber Remon <nilberremon@gmail.com>
This commit is contained in:
Nathan Shively-Sanders
2020-12-30 09:48:07 -08:00
committed by GitHub
parent 303ed3a357
commit 3b222fe80c
4 changed files with 9 additions and 9 deletions

View File

@@ -33382,7 +33382,7 @@ namespace ts {
if (isInJSFile(node)) {
const typeTag = getJSDocTypeTag(node);
if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
error(typeTag, Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
error(typeTag.typeExpression.type, Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
}
}
}