Skip to content

fix: remove redundant non-null assertions in ezoic.ts#1091

Open
yoloni-9527 wants to merge 1 commit intof:mainfrom
yoloni-9527:fix/remove-redundant-non-null-assertions-in-ezoic
Open

fix: remove redundant non-null assertions in ezoic.ts#1091
yoloni-9527 wants to merge 1 commit intof:mainfrom
yoloni-9527:fix/remove-redundant-non-null-assertions-in-ezoic

Conversation

@yoloni-9527
Copy link

@yoloni-9527 yoloni-9527 commented Mar 21, 2026

Summary

Hi there! 👋 Thanks for building and open-sourcing this project — really appreciate it.

I noticed a small TypeScript improvement opportunity in src/lib/ezoic.ts.

Problem

The ??= (nullish assignment) operator already guarantees that ez is non-null after assignment, so the non-null assertions (!) on the following lines are redundant:

// Before
const ez = (window.ezstandalone ??= {} as NonNullable<typeof window.ezstandalone>);
ez!.cmd = ez!.cmd || [];
ez!.cmd.push(fn);

The ! operator suppresses TypeScript's type checker unnecessarily, which can mask real issues in the future.

Fix

// After
const ez = (window.ezstandalone ??= {} as NonNullable<typeof window.ezstandalone>);
ez.cmd = ez.cmd || [];
ez.cmd.push(fn);

Impact

  • No behavior change — purely a type safety improvement
  • Removes 2 unnecessary ! non-null assertions
  • Lets TypeScript do its job without manual overrides

Happy to adjust anything if needed. Thanks again for the great project! 🙏

Summary by CodeRabbit

  • Refactor
    • Internal code improvements with no impact to user-facing functionality.

The ??= operator already guarantees that `ez` is non-null by the time
it is assigned, so the subsequent non-null assertions (!.) on `ez.cmd`
are redundant and can be safely removed.

Before:
  ez!.cmd = ez!.cmd || [];
  ez!.cmd.push(fn);

After:
  ez.cmd = ez.cmd || [];
  ez.cmd.push(fn);
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a3392f59-51ea-4428-8235-67f273e48cbf

📥 Commits

Reviewing files that changed from the base of the PR and between 08e85a3 and 256e433.

📒 Files selected for processing (1)
  • src/lib/ezoic.ts

📝 Walkthrough

Walkthrough

A single file refactoring removes non-null assertions (ez!.cmd) from runEzoic, replacing them with direct property access (ez.cmd). The initialization logic, queueing behavior, and function signature remain unchanged.

Changes

Cohort / File(s) Summary
Type Safety Improvement
src/lib/ezoic.ts
Removed non-null assertions on the ez object, replacing ez!.cmd with ez.cmd for cleaner type handling while maintaining identical initialization and queueing behavior.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Hops of clarity, assertions fade,
No more !'s in the queue parade,
Type-safe whiskers twitch with glee,
Ezoic flows more naturally! 🎯

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: removing redundant non-null assertions from ezoic.ts, which matches the primary objective of the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

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.

1 participant