-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Disallow whitespace before non-null assertion #56384
Closed
jakebailey
wants to merge
7
commits into
microsoft:main
from
jakebailey:ban-whitespace-after-exclamation
Closed
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f0079d2
Disallow whitespace before non-null assertion
jakebailey ad09b6a
PR feedback
jakebailey 42e63dc
Make formatting pass for now
jakebailey 1a18b72
Merge branch 'main' into ban-whitespace-after-exclamation
jakebailey 572fa4e
Update
jakebailey ee16840
Merge branch 'main' into ban-whitespace-after-exclamation
jakebailey 869383d
Modify message
jakebailey 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 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 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
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/parseNoWhitespaceBeforeExclamation.errors.txt
This file contains 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,18 @@ | ||
parseNoWhitespaceBeforeExclamation.ts(3,6): error TS1289: A non-null assertion may not be preceded by whitespace. | ||
parseNoWhitespaceBeforeExclamation.ts(4,6): error TS1289: A non-null assertion may not be preceded by whitespace. | ||
parseNoWhitespaceBeforeExclamation.ts(5,6): error TS1289: A non-null assertion may not be preceded by whitespace. | ||
|
||
|
||
==== parseNoWhitespaceBeforeExclamation.ts (3 errors) ==== | ||
declare var value: any; | ||
|
||
value !; | ||
~~ | ||
!!! error TS1289: A non-null assertion may not be preceded by whitespace. | ||
value !instanceof String; | ||
~~ | ||
!!! error TS1289: A non-null assertion may not be preceded by whitespace. | ||
value/* this is a comment */! instanceof String; | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1289: A non-null assertion may not be preceded by whitespace. | ||
|
14 changes: 14 additions & 0 deletions
14
tests/baselines/reference/parseNoWhitespaceBeforeExclamation.js
This file contains 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,14 @@ | ||
//// [tests/cases/compiler/parseNoWhitespaceBeforeExclamation.ts] //// | ||
|
||
//// [parseNoWhitespaceBeforeExclamation.ts] | ||
declare var value: any; | ||
|
||
value !; | ||
value !instanceof String; | ||
value/* this is a comment */! instanceof String; | ||
|
||
|
||
//// [parseNoWhitespaceBeforeExclamation.js] | ||
value; | ||
value instanceof String; | ||
value /* this is a comment */ instanceof String; |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/parseNoWhitespaceBeforeExclamation.symbols
This file contains 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,17 @@ | ||
//// [tests/cases/compiler/parseNoWhitespaceBeforeExclamation.ts] //// | ||
|
||
=== parseNoWhitespaceBeforeExclamation.ts === | ||
declare var value: any; | ||
>value : Symbol(value, Decl(parseNoWhitespaceBeforeExclamation.ts, 0, 11)) | ||
|
||
value !; | ||
>value : Symbol(value, Decl(parseNoWhitespaceBeforeExclamation.ts, 0, 11)) | ||
|
||
value !instanceof String; | ||
>value : Symbol(value, Decl(parseNoWhitespaceBeforeExclamation.ts, 0, 11)) | ||
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
||
value/* this is a comment */! instanceof String; | ||
>value : Symbol(value, Decl(parseNoWhitespaceBeforeExclamation.ts, 0, 11)) | ||
>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
|
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/parseNoWhitespaceBeforeExclamation.types
This file contains 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,22 @@ | ||
//// [tests/cases/compiler/parseNoWhitespaceBeforeExclamation.ts] //// | ||
|
||
=== parseNoWhitespaceBeforeExclamation.ts === | ||
declare var value: any; | ||
>value : any | ||
|
||
value !; | ||
>value ! : any | ||
>value : any | ||
|
||
value !instanceof String; | ||
>value !instanceof String : boolean | ||
>value ! : any | ||
>value : any | ||
>String : StringConstructor | ||
|
||
value/* this is a comment */! instanceof String; | ||
>value/* this is a comment */! instanceof String : boolean | ||
>value/* this is a comment */! : any | ||
>value : any | ||
>String : StringConstructor | ||
|
This file contains 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,5 @@ | ||
declare var value: any; | ||
|
||
value !; | ||
value !instanceof String; | ||
value/* this is a comment */! instanceof String; | ||
jakebailey marked this conversation as resolved.
Show resolved
Hide resolved
|
Oops, something went wrong.
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.
What about something like
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.
Also shockingly, we don't use the term "whitespace" anywhere in our messages.
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.
I like Daniel's too though