More actionable "must have annotation" message - #35839
Merged
Daniel Rosenwasser (DanielRosenwasser) merged 4 commits intoJan 8, 2020
Merged
Conversation
Daniel Rosenwasser (DanielRosenwasser)
requested a review
from Nathan Shively-Sanders (sandersn)
January 7, 2020 00:48
Nathan Shively-Sanders (sandersn)
approved these changes
Jan 8, 2020
| ~~~~~~ | ||
| !!! error TS2775: Assertions require every name in the call target to be declared with an explicit type annotation. | ||
| !!! related TS2728 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:144:11: 'assert' is declared here. | ||
| !!! related TS2782 tests/cases/conformance/controlFlow/assertionTypePredicates1.ts:144:11: 'assert' needs an explicit type annotation. |
There was a problem hiding this comment.
as far as I understand, this error was previously incorrect and is now still incorrect. the real problem is that we can't use asserts with arrow functions, right?
Member
Author
There was a problem hiding this comment.
No, the arrow function is fully annotated, but the assert declaration itself needs to be annotated. It's very stupid.
- const assert = (value: unknown): asserts value => { }
+ const assert: (value: unknown) => asserts value = (value: unknown): asserts value => { }
Member
Author
There was a problem hiding this comment.
Or "better"
- const assert = (value: unknown): asserts value => { }
+ const assert: (value: unknown) => asserts value = value => { }
Daniel Rosenwasser (DanielRosenwasser)
deleted the
mustHaveAnnotationMessage
branch
January 8, 2020 00:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #35838