-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Add test for #21317 #21349
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
Closed
Closed
Add test for #21317 #21349
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// <reference path="fourslash.ts" /> | ||
|
||
// @strictNullChecks: true | ||
|
||
////function test<T extends string | undefined>(x: T) { | ||
//// x/**/!; | ||
////} | ||
|
||
verify.typeAtLocation("", "string | undefined"); // TODO: GH#21317: should be "T". | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should remove the
TODO
(and maybe the PR?), the new type at this position is intended, not a bug; see my comment.We now consider the type at a location of a generic with a nullable constraint that is nonnull-asserted as having been narrowed to the nonnull part of its constraint (since usually you'd do this to access some member or call on it, like a cast).
Also, I'm pretty sure this is exactly what our
type
baselines test. We knew this changed and intended it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be
string
and notstring | undefined
then?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weswigham IMO the test is legitimate, because it tests the type before the assertion (what the issue is about) and not the result of the assertion.
Though maybe that's already covered by the baselines as you mentioned.
Either way the API issue should be fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type before the assertion is going to be the constraint (
string | undefined
, because it's an apparent position thanks to the assertion), and then after the assertion is applied it should just bestring
. This isn't an API issue, we legitimately interpret the type at that position as just the constraint now, that way the bang after it functions somewhat.