Update lint #1588

Closed
opened 2026-04-05 16:29:11 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @Gift-Stack on 10/5/2023

Title of this pull request?

Null asserted optional chain restriction

Small Description?

?. optional chain expressions provide undefined if an object is null or undefined. Using a ! non-null assertion to assert the result of an ?. optional chain expression is non-nullable and is likely wrong.

Most of the time, either the object was not nullable and did not need the ?. for its property lookup, or the ! is incorrect and introduces a type safety hole.

Pull Request Checklist:

  • Please make sure all jobs pass before requesting a review.
  • Put closes #XXXX in your comment to auto-close the issue that your PR fixes (if such).
  • Have you lint your code locally before submission?
  • Did you write tests where appropriate?

#43

Screenshots (if appropriate):

*Originally created by @Gift-Stack on 10/5/2023* ### Title of this pull request? Null asserted optional chain restriction ### Small Description? `?.` optional chain expressions provide undefined if an object is `null` or `undefined`. Using a `!` non-null assertion to assert the result of an `?.` optional chain expression is non-nullable and is likely wrong. > Most of the time, either the object was not nullable and did not need the `?.` for its property lookup, or the `!` is incorrect and introduces a type safety hole. ### Pull Request Checklist: - [x] Please make sure all jobs pass before requesting a review. - [x] Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). - [x] Have you lint your code locally before submission? - [ ] Did you write tests where appropriate? ### Related Issue? #43 ### Screenshots (if appropriate):
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#1588