refactor: remove unnecessary optional chaining, nullish coalescing, and type assertions#1238
Closed
314systems wants to merge 17 commits intoopennextjs:mainfrom
Closed
refactor: remove unnecessary optional chaining, nullish coalescing, and type assertions#1238314systems wants to merge 17 commits intoopennextjs:mainfrom
314systems wants to merge 17 commits intoopennextjs:mainfrom
Conversation
Co-authored-by: Copilot <copilot@github.com>
|
commit: |
Replace `length` checks followed by `arr[0]!` with destructuring (`const [x, ...rest] = arr`) and `undefined` guards. TypeScript does not narrow indexed access from a length check, so the previous code needed `!`; the destructured form narrows naturally and is type-safe without assertions. Co-authored-by: Copilot <copilot@github.com>
…l-og font patch Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Merged
Contributor
|
See #1239 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cleans up several spots in
packages/cloudflarewhere optional chaining (?.),nullish coalescing (
??), or non-null/type assertions (!,as) were guardingagainst states the types already preclude.
No behavioural changes intended.
(Note: Investigated by switching the ESLint config to
tseslint.configs.strictTypeCheckedand addressing the resulting warnings.)