Skip to content

refactor: remove unnecessary optional chaining, nullish coalescing, and type assertions#1238

Closed
314systems wants to merge 17 commits intoopennextjs:mainfrom
314systems:refactoring
Closed

refactor: remove unnecessary optional chaining, nullish coalescing, and type assertions#1238
314systems wants to merge 17 commits intoopennextjs:mainfrom
314systems:refactoring

Conversation

@314systems
Copy link
Copy Markdown
Contributor

@314systems 314systems commented Apr 28, 2026

Cleans up several spots in packages/cloudflare where optional chaining (?.),
nullish coalescing (??), or non-null/type assertions (!, as) were guarding
against states the types already preclude.

No behavioural changes intended.

(Note: Investigated by switching the ESLint config to tseslint.configs.strictTypeChecked and addressing the resulting warnings.)


Open in Devin Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 28, 2026

⚠️ No Changeset found

Latest commit: 0c4098b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 28, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@1238

commit: 0c4098b

@314systems 314systems marked this pull request as draft April 28, 2026 16:02
@314systems 314systems marked this pull request as ready for review April 28, 2026 22:24
314systems and others added 6 commits April 29, 2026 07:35
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>
@vicb vicb mentioned this pull request Apr 29, 2026
@vicb
Copy link
Copy Markdown
Contributor

vicb commented Apr 29, 2026

See #1239

@vicb vicb closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants