Skip to content
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

Conversation

jakebailey
Copy link
Member

@jakebailey jakebailey commented Nov 13, 2023

Prototype implementation just to run the test suite; this is wrong for comments and such and probably trailing trivia (if that is even possible).

A formatting test fails because we don't format code with syntax errors, which this of course introduces.

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 13, 2023
@jakebailey
Copy link
Member Author

@typescript-bot test top200
@typescript-bot user test this
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 13, 2023

Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at f0079d2. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 13, 2023

Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at f0079d2. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 13, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at f0079d2. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/56384/merge:

There were infrastructure failures potentially unrelated to your change:

  • 2 instances of "Package install failed"

Otherwise...

Something interesting changed - please have a look.

Details

puppeteer

packages/browsers/test/src/tsconfig.json

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

Comment on lines 39 to 41
value/* this is a comment */! in String;
~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1289: A non-null assertion may not be preceded by whitespace.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously this is not the way I want to emit this error; we can discuss this later of course.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with it? The inclusion of the ! itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complaining about a comment when there's no whitespace; I would have expected at least one tool to support some sort of interleaved comment a la /*@__PURE__*/ or something. Maybe that's silly. If we do want to complain about comments, then my message would need to be updated (which is fine).

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/56384/merge:

Everything looks good!

@jakebailey
Copy link
Member Author

Wow, really, nobody had this?

@DanielRosenwasser
Copy link
Member

Wow, really, nobody had this?

In the top 200? Seems reasonable.

From the search @gorosgobe did over at tc39/proposal-negated-in-instanceof#1 (comment), there are only 13 results where !in or !instanceof occur.

@@ -951,6 +951,10 @@
"category": "Error",
"code": 1288
},
"A non-null assertion may not be preceded by whitespace.": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like

Whitespace and comments are not allowed between the argument and '!' operator in a non-null assertion.

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-null assertion operator must immediately follow its expression

I like Daniel's too though

@@ -1801,6 +1801,10 @@
"category": "Error",
"code": 1537
},
"A non-null assertion must be preceded by an identifier.": {
Copy link
Member

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?

Copy link
Member Author

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

@jakebailey jakebailey closed this Jul 24, 2024
@towerofnix
Copy link

Hey, may I ask why you closed your own PR here? Just curious if there was any outside discussion or change of circumstance! (Here via tc39/proposal-negated-in-instanceof#1 (reference))

@jakebailey
Copy link
Member Author

It didn't catch any bugs and wasn't the right implementation anyway. Just keeping my PR list clean.

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
None yet
Development

Successfully merging this pull request may close these issues.

5 participants