Skip to content

Shrink error span on @type errors for signatures #42024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 30, 2020

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Dec 17, 2020

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.

Thanks @ashyamanning and @neuhelos!

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 <[email protected]>
Co-authored-by: Nilber Remon <[email protected]>
@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Dec 17, 2020
@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Dec 18, 2020

This error still is a little strange because it doesn't actually highlight the function declaration itself. You'd think it would switch to that with a "the signature is declared here.

Still an overall improvement! I don't think that should block anything.

@sandersn
Copy link
Member Author

@DanielRosenwasser I agree that's an improvement -- and this error message is specific to the @type mismatch, so it's possible to reword this to be better. It's certainly not clear as-is. I'll add your suggestion to the original bug, since it's still open.

@sandersn sandersn merged commit 3b222fe into master Dec 30, 2020
@sandersn sandersn deleted the improve-type-tag-error-spans branch January 9, 2021 00:41
Zzzen pushed a commit to Zzzen/TypeScript that referenced this pull request Jan 16, 2021
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 microsoft#41974, but not the other two.

Co-authored-by: Ashya Manning <[email protected]>
Co-authored-by: Nilber Remon <[email protected]>

Co-authored-by: Ashya Manning <[email protected]>
Co-authored-by: Nilber Remon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants