-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Disallow whitespace before non-null assertion #56384
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
jakebailey
wants to merge
7
commits into
microsoft:main
from
jakebailey:ban-whitespace-after-exclamation
Closed
Changes from all commits
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 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
42 changes: 42 additions & 0 deletions
42
tests/baselines/reference/parseNoWhitespaceBeforeExclamation.errors.txt
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,42 @@ | ||
parseNoWhitespaceBeforeExclamation.ts(3,6): error TS1538: A non-null assertion must be preceded by an identifier. | ||
parseNoWhitespaceBeforeExclamation.ts(4,6): error TS1538: A non-null assertion must be preceded by an identifier. | ||
parseNoWhitespaceBeforeExclamation.ts(5,6): error TS1538: A non-null assertion must be preceded by an identifier. | ||
parseNoWhitespaceBeforeExclamation.ts(6,6): error TS1538: A non-null assertion must be preceded by an identifier. | ||
parseNoWhitespaceBeforeExclamation.ts(7,6): error TS1538: A non-null assertion must be preceded by an identifier. | ||
parseNoWhitespaceBeforeExclamation.ts(8,6): error TS1538: A non-null assertion must be preceded by an identifier. | ||
parseNoWhitespaceBeforeExclamation.ts(9,6): error TS1538: A non-null assertion must be preceded by an identifier. | ||
parseNoWhitespaceBeforeExclamation.ts(10,6): error TS1538: A non-null assertion must be preceded by an identifier. | ||
parseNoWhitespaceBeforeExclamation.ts(11,6): error TS1538: A non-null assertion must be preceded by an identifier. | ||
|
||
|
||
==== parseNoWhitespaceBeforeExclamation.ts (9 errors) ==== | ||
declare var value: any; | ||
|
||
value !; | ||
~~ | ||
!!! error TS1538: A non-null assertion must be preceded by an identifier. | ||
value !instanceof String; | ||
~~ | ||
!!! error TS1538: A non-null assertion must be preceded by an identifier. | ||
value ! instanceof String | ||
~~ | ||
!!! error TS1538: A non-null assertion must be preceded by an identifier. | ||
value/* this is a comment */!instanceof String; | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1538: A non-null assertion must be preceded by an identifier. | ||
value/* this is a comment */! instanceof String; | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1538: A non-null assertion must be preceded by an identifier. | ||
value !in String; | ||
~~ | ||
!!! error TS1538: A non-null assertion must be preceded by an identifier. | ||
value ! in String | ||
~~ | ||
!!! error TS1538: A non-null assertion must be preceded by an identifier. | ||
value/* this is a comment */!in String; | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1538: A non-null assertion must be preceded by an identifier. | ||
value/* this is a comment */! in String; | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
!!! error TS1538: A non-null assertion must be preceded by an identifier. | ||
|
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/parseNoWhitespaceBeforeExclamation.js
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,26 @@ | ||
//// [tests/cases/compiler/parseNoWhitespaceBeforeExclamation.ts] //// | ||
|
||
//// [parseNoWhitespaceBeforeExclamation.ts] | ||
declare var value: any; | ||
|
||
value !; | ||
value !instanceof String; | ||
value ! instanceof String | ||
value/* this is a comment */!instanceof String; | ||
value/* this is a comment */! instanceof String; | ||
value !in String; | ||
value ! in String | ||
value/* this is a comment */!in String; | ||
value/* this is a comment */! in String; | ||
|
||
|
||
//// [parseNoWhitespaceBeforeExclamation.js] | ||
value; | ||
value instanceof String; | ||
value instanceof String; | ||
value /* this is a comment */ instanceof String; | ||
value /* this is a comment */ instanceof String; | ||
value in String; | ||
value in String; | ||
value /* this is a comment */ in String; | ||
value /* this is a comment */ in String; |
41 changes: 41 additions & 0 deletions
41
tests/baselines/reference/parseNoWhitespaceBeforeExclamation.symbols
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,41 @@ | ||
//// [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 ! 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, --, --)) | ||
|
||
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, --, --)) | ||
|
||
value !in 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 ! in 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 */!in 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 */! in 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, --, --)) | ||
|
93 changes: 93 additions & 0 deletions
93
tests/baselines/reference/parseNoWhitespaceBeforeExclamation.types
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,93 @@ | ||
//// [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 ! 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 | ||
> : ^^^^^^^^^^^^^^^^^ | ||
|
||
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 | ||
> : ^^^^^^^^^^^^^^^^^ | ||
|
||
value !in String; | ||
>value !in String : boolean | ||
> : ^^^^^^^ | ||
>value ! : any | ||
> : ^^^ | ||
>value : any | ||
> : ^^^ | ||
>String : StringConstructor | ||
> : ^^^^^^^^^^^^^^^^^ | ||
|
||
value ! in String | ||
>value ! in String : boolean | ||
> : ^^^^^^^ | ||
>value ! : any | ||
> : ^^^ | ||
>value : any | ||
> : ^^^ | ||
>String : StringConstructor | ||
> : ^^^^^^^^^^^^^^^^^ | ||
|
||
value/* this is a comment */!in String; | ||
>value/* this is a comment */!in String : boolean | ||
> : ^^^^^^^ | ||
>value/* this is a comment */! : any | ||
> : ^^^ | ||
>value : any | ||
> : ^^^ | ||
>String : StringConstructor | ||
> : ^^^^^^^^^^^^^^^^^ | ||
|
||
value/* this is a comment */! in String; | ||
>value/* this is a comment */! in String : boolean | ||
> : ^^^^^^^ | ||
>value/* this is a comment */! : any | ||
> : ^^^ | ||
>value : any | ||
> : ^^^ | ||
>String : StringConstructor | ||
> : ^^^^^^^^^^^^^^^^^ | ||
|
11 changes: 11 additions & 0 deletions
11
tests/cases/compiler/parseNoWhitespaceBeforeExclamation.ts
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,11 @@ | ||
declare var value: any; | ||
|
||
value !; | ||
value !instanceof String; | ||
value ! instanceof String | ||
value/* this is a comment */!instanceof String; | ||
value/* this is a comment */! instanceof String; | ||
value !in String; | ||
value ! in String | ||
value/* this is a comment */!in String; | ||
value/* this is a comment */! in String; |
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
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.
identifier? Isn't that misleading?
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 guess
a[b]!
. bleh